FileOperationsMixin¶
Provides basic file operations.
Methods¶
exists¶
Check if the file exists.
Returns:
- bool: True if the file exists, False otherwise
Example:
is_dirty¶
Check if the file is dirty (has unsaved changes).
Returns:
- bool: True if the file has unsaved changes, False otherwise
Example:
is_loaded¶
Check if the file is loaded in memory.
Returns:
- bool: True if the file is loaded, False otherwise
Example:
load¶
Load data from the file.
Raises:
- FileNotFoundError: If the file doesn't exist and auto_create is False
- ValueError: If the file format is invalid or corrupted
- LoadFileError: If there's an error during the loading process
Example:
save¶
Save data to the file.
Raises:
- PermissionError: If the file cannot be written due to permissions
- ValueError: If the data format is invalid for the file type
- FileWriteError: If there's an error during the writing process
Example:
save_if_dirty¶
Save the file only if it has been modified.
Example:
reload¶
Reload data from the file, discarding any unsaved changes.
Example:
mark_as_dirty¶
Mark the file as dirty (has unsaved changes).
Example:
mark_as_clean¶
Mark the file as clean (no unsaved changes).
Example:
mark_as_loaded¶
Mark the file as loaded in memory.
Example:
unload¶
Unload the file from memory.
Example:
create_empty_file¶
Create an empty file.
Example:
load_if_not_loaded¶
Load the file if it is not loaded.
Example: