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::LoadProjectWithRom(), yaze::editor::EditorManager::LoadRom(), yaze::editor::EditorManager::OpenRomOrProject(), OpenRomOrProject(), and yaze::editor::EditorManager::RestoreRomBackup().

| 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::SaveRom().

| 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, 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::SaveRomAs().

| absl::Status yaze::editor::RomFileManager::OpenRomOrProject | ( | Rom * | rom, |
| const std::string & | filename ) |
Definition at line 126 of file rom_file_manager.cc.
References LoadRom().

| absl::Status yaze::editor::RomFileManager::CreateBackup | ( | Rom * | rom | ) |
Definition at line 145 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 yaze::editor::MenuOrchestrator::OnCreateBackup(), SaveRom(), and SaveRomAs().
| absl::Status yaze::editor::RomFileManager::ValidateRom | ( | Rom * | rom | ) |
Definition at line 188 of file rom_file_manager.cc.
References IsRomLoaded(), yaze::editor::kSuccess, yaze::editor::ToastManager::Show(), yaze::Rom::size(), yaze::Rom::title(), and toast_manager_.
Referenced by yaze::editor::MenuOrchestrator::OnValidateRom().

|
inline |
Definition at line 40 of file rom_file_manager.h.
References backup_folder_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy(), and yaze::editor::EditorManager::LoadProjectWithRom().
|
inline |
Definition at line 41 of file rom_file_manager.h.
References backup_before_save_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy(), and yaze::editor::EditorManager::LoadProjectWithRom().
|
inline |
Definition at line 42 of file rom_file_manager.h.
References backup_retention_count_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy(), and yaze::editor::EditorManager::LoadProjectWithRom().
|
inline |
Definition at line 43 of file rom_file_manager.h.
References backup_keep_daily_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy(), and yaze::editor::EditorManager::LoadProjectWithRom().
|
inline |
Definition at line 44 of file rom_file_manager.h.
References backup_keep_daily_days_.
Referenced by yaze::editor::RomLifecycleManager::ApplyDefaultBackupPolicy(), and yaze::editor::EditorManager::LoadProjectWithRom().
| std::vector< RomFileManager::BackupEntry > yaze::editor::RomFileManager::ListBackups | ( | const std::string & | rom_filename | ) | const |
Definition at line 284 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(), and PruneBackups().

| absl::Status yaze::editor::RomFileManager::PruneBackups | ( | const std::string & | rom_filename | ) | const |
Definition at line 329 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 206 of file rom_file_manager.cc.
References yaze::Rom::is_loaded().
Referenced by yaze::editor::MenuOrchestrator::CanSaveRom(), CreateBackup(), GetRomFilename(), yaze::editor::MenuOrchestrator::HasActiveRom(), SaveRom(), SaveRomAs(), and ValidateRom().

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

|
private |
Definition at line 217 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 249 of file rom_file_manager.cc.
References GetBackupDirectory().
Referenced by CreateBackup().

|
private |
Definition at line 272 of file rom_file_manager.cc.
References backup_folder_.
Referenced by GenerateBackupFilename(), and ListBackups().
|
private |
Definition at line 384 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().