Handles all ROM file I/O operations. More...
#include <rom_file_manager.h>

Classes | |
| struct | BackupEntry |
Public Member Functions | |
| RomFileManager (ToastManager *toast_manager) | |
| ~RomFileManager ()=default | |
| absl::Status | LoadRom (Rom *rom, const std::string &filename) |
| absl::Status | SaveRom (Rom *rom) |
| absl::Status | SaveRomAs (Rom *rom, const std::string &filename) |
| absl::Status | OpenRomOrProject (Rom *rom, const std::string &filename) |
| absl::Status | CreateBackup (Rom *rom) |
| absl::Status | ValidateRom (Rom *rom) |
| void | SetBackupFolder (const std::string &folder) |
| void | SetBackupBeforeSave (bool enabled) |
| void | SetBackupRetentionCount (int count) |
| void | SetBackupKeepDaily (bool enabled) |
| void | SetBackupKeepDailyDays (int days) |
| std::vector< BackupEntry > | ListBackups (const std::string &rom_filename) const |
| absl::Status | PruneBackups (const std::string &rom_filename) const |
| bool | IsRomLoaded (Rom *rom) const |
| std::string | GetRomFilename (Rom *rom) const |
Private Member Functions | |
| absl::Status | LoadRomFromFile (Rom *rom, const std::string &filename) |
| std::string | GenerateBackupFilename (const std::string &original_filename) const |
| std::filesystem::path | GetBackupDirectory (const std::string &original_filename) const |
| bool | IsValidRomFile (const std::string &filename) const |
Private Attributes | |
| ToastManager * | toast_manager_ = nullptr |
| bool | backup_before_save_ = true |
| std::string | backup_folder_ |
| int | backup_retention_count_ = 20 |
| bool | backup_keep_daily_ = true |
| int | backup_keep_daily_days_ = 14 |
Handles all ROM file I/O operations.
Extracted from EditorManager to provide focused ROM file management:
Definition at line 27 of file rom_file_manager.h.
|
explicit |
Definition at line 43 of file rom_file_manager.cc.
|
default |
| absl::Status yaze::editor::RomFileManager::LoadRom | ( | Rom * | rom, |
| const std::string & | filename ) |
Definition at line 46 of file rom_file_manager.cc.
References LoadRomFromFile().
Referenced by yaze::editor::EditorManager::DiscardPendingRomBackupRestore(), yaze::editor::EditorManager::LoadProjectWithRom(), yaze::editor::EditorManager::LoadRomInternal(), OpenRomOrProject(), yaze::editor::EditorManager::OpenRomOrProjectInternal(), yaze::editor::EditorManager::ReloadProjectRom(), yaze::editor::EditorManager::RestoreRomBackup(), yaze::editor::EditorManager::RunCurrentProject(), yaze::editor::EditorManager::SwapProjectRom(), and yaze::editor::EditorManager::ValidateProjectRomSelection().

| absl::Status yaze::editor::RomFileManager::SaveRom | ( | Rom * | rom | ) |
Definition at line 56 of file rom_file_manager.cc.
References yaze::Rom::SaveSettings::backup, backup_before_save_, CreateBackup(), IsRomLoaded(), yaze::editor::kError, yaze::editor::kSuccess, yaze::Rom::SaveSettings::save_new, yaze::Rom::SaveToFile(), yaze::editor::ToastManager::Show(), and toast_manager_.
Referenced by yaze::editor::EditorManager::SaveRomInternal().

| absl::Status yaze::editor::RomFileManager::SaveRomAs | ( | Rom * | rom, |
| const std::string & | filename ) |
Definition at line 88 of file rom_file_manager.cc.
References yaze::Rom::SaveSettings::backup, backup_before_save_, CreateBackup(), yaze::Rom::SaveSettings::filename, yaze::Rom::filename(), IsRomLoaded(), yaze::editor::kError, yaze::editor::kSuccess, yaze::Rom::SaveSettings::save_new, yaze::Rom::SaveToFile(), yaze::Rom::set_filename(), yaze::editor::ToastManager::Show(), and toast_manager_.
Referenced by yaze::editor::EditorManager::SaveRomInternal().
| absl::Status yaze::editor::RomFileManager::OpenRomOrProject | ( | Rom * | rom, |
| const std::string & | filename ) |
Definition at line 134 of file rom_file_manager.cc.
References LoadRom().

| absl::Status yaze::editor::RomFileManager::CreateBackup | ( | Rom * | rom | ) |
Definition at line 153 of file rom_file_manager.cc.
References yaze::Rom::filename(), GenerateBackupFilename(), IsRomLoaded(), yaze::editor::kError, yaze::editor::kSuccess, LOG_WARN, PruneBackups(), yaze::editor::ToastManager::Show(), and toast_manager_.
Referenced by SaveRom(), and SaveRomAs().
| absl::Status yaze::editor::RomFileManager::ValidateRom | ( | Rom * | rom | ) |
Definition at line 196 of file rom_file_manager.cc.
References IsRomLoaded(), yaze::editor::kSuccess, yaze::editor::ToastManager::Show(), yaze::Rom::size(), yaze::Rom::title(), and toast_manager_.

|
inline |
Definition at line 40 of file rom_file_manager.h.
References backup_folder_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy().
|
inline |
Definition at line 41 of file rom_file_manager.h.
References backup_before_save_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy().
|
inline |
Definition at line 42 of file rom_file_manager.h.
References backup_retention_count_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy().
|
inline |
Definition at line 43 of file rom_file_manager.h.
References backup_keep_daily_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy().
|
inline |
Definition at line 44 of file rom_file_manager.h.
References backup_keep_daily_days_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy().
| std::vector< RomFileManager::BackupEntry > yaze::editor::RomFileManager::ListBackups | ( | const std::string & | rom_filename | ) | const |
Definition at line 291 of file rom_file_manager.cc.
References yaze::editor::RomFileManager::BackupEntry::filename, GetBackupDirectory(), yaze::editor::RomFileManager::BackupEntry::path, yaze::editor::RomFileManager::BackupEntry::size_bytes, and yaze::editor::RomFileManager::BackupEntry::timestamp.
Referenced by yaze::editor::RomLifecycleManager::GetRomBackups(), PruneBackups(), and yaze::editor::EditorManager::RestoreRomBackup().

| absl::Status yaze::editor::RomFileManager::PruneBackups | ( | const std::string & | rom_filename | ) | const |
Definition at line 337 of file rom_file_manager.cc.
References backup_keep_daily_, backup_keep_daily_days_, backup_retention_count_, ListBackups(), and LOG_WARN.
Referenced by CreateBackup(), and yaze::editor::RomLifecycleManager::PruneRomBackups().

| bool yaze::editor::RomFileManager::IsRomLoaded | ( | Rom * | rom | ) | const |
Definition at line 214 of file rom_file_manager.cc.
References yaze::Rom::is_loaded().
Referenced by CreateBackup(), GetRomFilename(), SaveRom(), SaveRomAs(), and ValidateRom().

| std::string yaze::editor::RomFileManager::GetRomFilename | ( | Rom * | rom | ) | const |
Definition at line 218 of file rom_file_manager.cc.
References yaze::Rom::filename(), and IsRomLoaded().

|
private |
Definition at line 225 of file rom_file_manager.cc.
References IsValidRomFile(), yaze::editor::kError, yaze::editor::kSuccess, yaze::Rom::LoadFromFile(), yaze::editor::ToastManager::Show(), yaze::Rom::title(), and toast_manager_.
Referenced by LoadRom().

|
private |
Definition at line 257 of file rom_file_manager.cc.
References GetBackupDirectory().
Referenced by CreateBackup().

|
private |
Definition at line 279 of file rom_file_manager.cc.
References backup_folder_.
Referenced by GenerateBackupFilename(), and ListBackups().
|
private |
Definition at line 393 of file rom_file_manager.cc.
Referenced by LoadRomFromFile().
|
private |
Definition at line 62 of file rom_file_manager.h.
Referenced by CreateBackup(), LoadRomFromFile(), SaveRom(), SaveRomAs(), and ValidateRom().
|
private |
Definition at line 71 of file rom_file_manager.h.
Referenced by SaveRom(), SaveRomAs(), and SetBackupBeforeSave().
|
private |
Definition at line 72 of file rom_file_manager.h.
Referenced by GetBackupDirectory(), and SetBackupFolder().
|
private |
Definition at line 73 of file rom_file_manager.h.
Referenced by PruneBackups(), and SetBackupRetentionCount().
|
private |
Definition at line 74 of file rom_file_manager.h.
Referenced by PruneBackups(), and SetBackupKeepDaily().
|
private |
Definition at line 75 of file rom_file_manager.h.
Referenced by PruneBackups(), and SetBackupKeepDailyDays().