mirror of
https://git.eden-emu.dev/archive/citron
synced 2026-04-04 10:30:12 -04:00
feat(fs): Implement Global Custom Save Path
Added a "Global Custom Save Path" configuration option in the Filesystem settings. Implemented a prioritized save-loading hierarchy: Global Path (if enabled) > Per-Game Custom Path > Default NAND. Introduced a non-destructive migration tool that allows users to consolidate their existing saves into the new global location. The migration tool specifically prioritizes per-game custom saves over NAND saves to ensure the most up-to-date data is preserved during consolidation. The migration process is copy-only; no data is deleted from the source directories, ensuring absolute user data safety. Maintained compatibility with the existing "Backup Saves to NAND" feature, ensuring saves continue to be mirrored internally if configured. Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
@@ -422,17 +422,22 @@ std::shared_ptr<FileSys::SaveDataFactory> FileSystemController::CreateSaveDataFa
|
|||||||
const auto rw_mode = FileSys::OpenMode::ReadWrite;
|
const auto rw_mode = FileSys::OpenMode::ReadWrite;
|
||||||
auto vfs = system.GetFilesystem();
|
auto vfs = system.GetFilesystem();
|
||||||
|
|
||||||
// Check for a custom save path for the current game.
|
std::string custom_path_str;
|
||||||
if (Settings::values.custom_save_paths.count(program_id)) {
|
|
||||||
const std::string& custom_path_str = Settings::values.custom_save_paths.at(program_id);
|
// 1. Priority 1: Global Override
|
||||||
|
if (Settings::values.global_custom_save_path_enabled.GetValue()) {
|
||||||
|
custom_path_str = Settings::values.global_custom_save_path.GetValue();
|
||||||
|
}
|
||||||
|
// 2. Priority 2: Individual Game Override
|
||||||
|
else if (Settings::values.custom_save_paths.count(program_id)) {
|
||||||
|
custom_path_str = Settings::values.custom_save_paths.at(program_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If any custom logic is hit, use that path but KEEP NAND as backup target
|
||||||
|
if (!custom_path_str.empty()) {
|
||||||
const std::filesystem::path custom_path = custom_path_str;
|
const std::filesystem::path custom_path = custom_path_str;
|
||||||
|
if (Common::FS::IsDir(custom_path)) {
|
||||||
// If the custom path is valid and points to a directory, use it.
|
|
||||||
if (!custom_path_str.empty() && Common::FS::IsDir(custom_path)) {
|
|
||||||
LOG_INFO(Service_FS, "Using custom save path for program_id={:016X}: {}", program_id, custom_path_str);
|
|
||||||
auto custom_save_directory = vfs->OpenDirectory(custom_path_str, rw_mode);
|
auto custom_save_directory = vfs->OpenDirectory(custom_path_str, rw_mode);
|
||||||
|
|
||||||
// Fetch the default NAND directory to act as the backup location
|
|
||||||
auto nand_directory = vfs->OpenDirectory(Common::FS::GetCitronPathString(CitronPath::NANDDir), rw_mode);
|
auto nand_directory = vfs->OpenDirectory(Common::FS::GetCitronPathString(CitronPath::NANDDir), rw_mode);
|
||||||
|
|
||||||
return std::make_shared<FileSys::SaveDataFactory>(
|
return std::make_shared<FileSys::SaveDataFactory>(
|
||||||
@@ -440,12 +445,10 @@ std::shared_ptr<FileSys::SaveDataFactory> FileSystemController::CreateSaveDataFa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If no valid custom path was found, use the default NAND directory.
|
// 3. Fallback: Standard NAND
|
||||||
const auto nand_directory =
|
const auto nand_directory = vfs->OpenDirectory(Common::FS::GetCitronPathString(CitronPath::NANDDir), rw_mode);
|
||||||
vfs->OpenDirectory(Common::FS::GetCitronPathString(CitronPath::NANDDir), rw_mode);
|
return std::make_shared<FileSys::SaveDataFactory>(system, program_id, std::move(nand_directory));
|
||||||
return std::make_shared<FileSys::SaveDataFactory>(system, program_id,
|
}
|
||||||
std::move(nand_directory));
|
|
||||||
}
|
|
||||||
|
|
||||||
Result FileSystemController::OpenSDMC(FileSys::VirtualDir* out_sdmc) const {
|
Result FileSystemController::OpenSDMC(FileSys::VirtualDir* out_sdmc) const {
|
||||||
LOG_TRACE(Service_FS, "Opening SDMC");
|
LOG_TRACE(Service_FS, "Opening SDMC");
|
||||||
|
|||||||
Reference in New Issue
Block a user