diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 240762d25a..dce84e94b4 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -1222,7 +1222,7 @@ void Module::Interface::GetProgramInfoFromCia(Kernel::HLERequestContext& ctx) { return; } - FileSys::TitleMetadata tmd = container.GetTitleMetadata(); + const FileSys::TitleMetadata& tmd = container.GetTitleMetadata(); TitleInfo title_info = {}; container.Print(); diff --git a/src/core/hle/service/cecd/cecd.cpp b/src/core/hle/service/cecd/cecd.cpp index 977a478421..9c3cfa0abc 100644 --- a/src/core/hle/service/cecd/cecd.cpp +++ b/src/core/hle/service/cecd/cecd.cpp @@ -1381,7 +1381,7 @@ Module::Module(Core::System& system) : system(system) { change_state_event = system.Kernel().CreateEvent(Kernel::ResetType::OneShot, "CECD::change_state_event"); - std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory); // Open the SystemSaveData archive 0x00010026 diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index fc285f6625..982dc03f48 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -555,7 +555,7 @@ ResultCode Module::FormatConfig() { } // namespace Service::CFG ResultCode Module::LoadConfigNANDSaveFile() { - std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); FileSys::ArchiveFactory_SystemSaveData systemsavedata_factory(nand_directory); // Open the SystemSaveData archive 0x00010017 diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp index c4ed0d42cb..8da2bf52e8 100644 --- a/src/core/hle/service/fs/archive.cpp +++ b/src/core/hle/service/fs/archive.cpp @@ -267,25 +267,29 @@ ResultCode ArchiveManager::DeleteExtSaveData(MediaType media_type, u32 high, u32 ResultCode ArchiveManager::DeleteSystemSaveData(u32 high, u32 low) { // Construct the binary path to the archive first - FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); + const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); - std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); - std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); - std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); - if (!FileUtil::DeleteDirRecursively(systemsavedata_path)) + const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); + const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); + if (!FileUtil::DeleteDirRecursively(systemsavedata_path)) { return ResultCode(-1); // TODO(Subv): Find the right error code + } + return RESULT_SUCCESS; } ResultCode ArchiveManager::CreateSystemSaveData(u32 high, u32 low) { // Construct the binary path to the archive first - FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); + const FileSys::Path path = FileSys::ConstructSystemSaveDataBinaryPath(high, low); - std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); - std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); - std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); - if (!FileUtil::CreateFullPath(systemsavedata_path)) + const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string base_path = FileSys::GetSystemSaveDataContainerPath(nand_directory); + const std::string systemsavedata_path = FileSys::GetSystemSaveDataPath(base_path, path); + if (!FileUtil::CreateFullPath(systemsavedata_path)) { return ResultCode(-1); // TODO(Subv): Find the right error code + } + return RESULT_SUCCESS; } diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 430d48cdd9..9c4c09fad3 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -134,7 +134,7 @@ void Module::Interface::CheckNew3DS(Kernel::HLERequestContext& ctx) { } static void WriteGameCoinData(GameCoin gamecoin_data) { - std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true); FileSys::Path archive_path(ptm_shared_extdata_id); @@ -167,7 +167,7 @@ static void WriteGameCoinData(GameCoin gamecoin_data) { } static GameCoin ReadGameCoinData() { - std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true); FileSys::Path archive_path(ptm_shared_extdata_id); @@ -197,10 +197,10 @@ static GameCoin ReadGameCoinData() { Module::Module() { // Open the SharedExtSaveData archive 0xF000000B and create the gamecoin.dat file if it doesn't // exist - std::string nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); + const std::string& nand_directory = FileUtil::GetUserPath(FileUtil::UserPath::NANDDir); FileSys::ArchiveFactory_ExtSaveData extdata_archive_factory(nand_directory, true); - FileSys::Path archive_path(ptm_shared_extdata_id); - auto archive_result = extdata_archive_factory.Open(archive_path, 0); + const FileSys::Path archive_path(ptm_shared_extdata_id); + const auto archive_result = extdata_archive_factory.Open(archive_path, 0); // If the archive didn't exist, write the default game coin file if (archive_result.Code() == FileSys::ERR_NOT_FORMATTED) { WriteGameCoinData(default_game_coin);