From 2e8d5992a2c2113de04dcc69b59d89f16a8f465d Mon Sep 17 00:00:00 2001 From: Collecting Date: Mon, 29 Dec 2025 01:12:50 +0000 Subject: [PATCH] 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 --- .../hle/service/filesystem/filesystem.cpp | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index edb7d6ede..84aa313f9 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -422,17 +422,22 @@ std::shared_ptr FileSystemController::CreateSaveDataFa const auto rw_mode = FileSys::OpenMode::ReadWrite; auto vfs = system.GetFilesystem(); - // Check for a custom save path for the current game. - if (Settings::values.custom_save_paths.count(program_id)) { - const std::string& custom_path_str = Settings::values.custom_save_paths.at(program_id); + std::string custom_path_str; + + // 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; - - // 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); + if (Common::FS::IsDir(custom_path)) { 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); return std::make_shared( @@ -440,12 +445,10 @@ std::shared_ptr FileSystemController::CreateSaveDataFa } } - // If no valid custom path was found, use the default NAND directory. - const auto nand_directory = - vfs->OpenDirectory(Common::FS::GetCitronPathString(CitronPath::NANDDir), rw_mode); - return std::make_shared(system, program_id, - std::move(nand_directory)); -} + // 3. Fallback: Standard NAND + const auto nand_directory = vfs->OpenDirectory(Common::FS::GetCitronPathString(CitronPath::NANDDir), rw_mode); + return std::make_shared(system, program_id, std::move(nand_directory)); + } Result FileSystemController::OpenSDMC(FileSys::VirtualDir* out_sdmc) const { LOG_TRACE(Service_FS, "Opening SDMC");