From 72915f88c866c106be3d3661f734a21d3fa6bfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 30 May 2021 12:39:16 +0200 Subject: [PATCH 1/2] Config: Remove the use of multiple search paths. --- Common/File/FileUtil.cpp | 4 ++-- Core/Config.cpp | 5 ++++- Core/System.h | 3 +++ UWP/PPSSPP_UWPMain.cpp | 5 +---- Windows/main.cpp | 1 - 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Common/File/FileUtil.cpp b/Common/File/FileUtil.cpp index f1c12ede97..2536d4bdf7 100644 --- a/Common/File/FileUtil.cpp +++ b/Common/File/FileUtil.cpp @@ -364,10 +364,10 @@ bool CreateFullPath(const Path &path) { std::string fullPath = path.ToString(); int panicCounter = 100; - VERBOSE_LOG(COMMON, "CreateFullPath: path %s", fullPath.c_str()); + VERBOSE_LOG(COMMON, "CreateFullPath: '%s'", fullPath.c_str()); if (File::Exists(fullPath)) { - DEBUG_LOG(COMMON, "CreateFullPath: path exists %s", fullPath.c_str()); + DEBUG_LOG(COMMON, "CreateFullPath: path already exists: '%s'", fullPath.c_str()); return true; } diff --git a/Core/Config.cpp b/Core/Config.cpp index 3ac1112b20..fbb22d8228 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1607,7 +1607,10 @@ const Path Config::FindConfigFile(const std::string &baseFilename) { if (!File::Exists(filename)) { // Make sure at least the directory it's supposed to be in exists. Path path = filename.NavigateUp(); - File::CreateFullPath(path); + // This check is just to avoid logging. + if (!File::Exists(path)) { + File::CreateFullPath(path); + } } return filename; } diff --git a/Core/System.h b/Core/System.h index c66e45ab67..d9e3cdb3a1 100644 --- a/Core/System.h +++ b/Core/System.h @@ -97,7 +97,10 @@ bool IsAudioInitialised(); void UpdateLoadedFile(FileLoader *fileLoader); +// NOTE: These are almost all derived from g_Config.memStickDirectory directly - +// they are not stored anywhere. Path GetSysDirectory(PSPDirectories directoryType); + #ifdef _WIN32 void InitSysDirectories(); #endif diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 949eaf0df1..a4a8852192 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -92,9 +92,6 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptrLocalFolder->Path->Data(); g_Config.memStickDirectory = Path(memstickFolderW); @@ -108,7 +105,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr Date: Sun, 30 May 2021 12:45:12 +0200 Subject: [PATCH 2/2] Remove the ability to have multiple search paths for config. --- Core/Config.cpp | 29 ++++++++++------------------- Core/Config.h | 8 ++------ UI/NativeApp.cpp | 5 ++--- UWP/PPSSPP_UWPMain.cpp | 3 +-- Windows/main.cpp | 3 +-- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index fbb22d8228..74be99d75e 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -1577,12 +1577,8 @@ void Config::CleanRecent() { recentIsos = cleanedRecent; } -void Config::SetDefaultPath(const Path &defaultPath) { - defaultPath_ = defaultPath; -} - -void Config::AddSearchPath(const Path &path) { - searchPath_.push_back(path); +void Config::SetSearchPath(const Path &searchPath) { + searchPath_ = searchPath; } const Path Config::FindConfigFile(const std::string &baseFilename) { @@ -1596,21 +1592,16 @@ const Path Config::FindConfigFile(const std::string &baseFilename) { } #endif - for (size_t i = 0; i < searchPath_.size(); ++i) { - Path filename = searchPath_[i] / baseFilename; - if (File::Exists(filename)) { - return filename; - } + Path filename = searchPath_ / baseFilename; + if (File::Exists(filename)) { + return filename; } - const Path filename = defaultPath_ / baseFilename; - if (!File::Exists(filename)) { - // Make sure at least the directory it's supposed to be in exists. - Path path = filename.NavigateUp(); - // This check is just to avoid logging. - if (!File::Exists(path)) { - File::CreateFullPath(path); - } + // Make sure at least the directory it's supposed to be in exists. + Path path = filename.NavigateUp(); + // This check is just to avoid logging. + if (!File::Exists(path)) { + File::CreateFullPath(path); } return filename; } diff --git a/Core/Config.h b/Core/Config.h index 49211f29db..79323eefca 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -505,10 +505,7 @@ public: Path getGameConfigFile(const std::string &gameId); bool hasGameConfig(const std::string &game_id); - // Used when the file is not found in the search path. Trailing slash. - void SetDefaultPath(const Path &defaultPath); - // Use a trailing slash. - void AddSearchPath(const Path &path); + void SetSearchPath(const Path &path); const Path FindConfigFile(const std::string &baseFilename); // Utility functions for "recent" management @@ -536,8 +533,7 @@ private: std::string gameIdTitle_; Path iniFilename_; Path controllerIniFilename_; - std::vector searchPath_; - Path defaultPath_; + Path searchPath_; }; std::map> GetLangValuesMapping(); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 065482d4a2..e1edded499 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -539,14 +539,13 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch LogManager::Init(&g_Config.bEnableLogging); #if !PPSSPP_PLATFORM(WINDOWS) - g_Config.AddSearchPath(Path(user_data_path)); - g_Config.AddSearchPath(GetSysDirectory(DIRECTORY_SYSTEM)); - g_Config.SetDefaultPath(GetSysDirectory(DIRECTORY_SYSTEM)); + g_Config.SetSearchPath(GetSysDirectory(DIRECTORY_SYSTEM)); // Note that if we don't have storage permission here, loading the config will // fail and it will be set to the default. Later, we load again when we get permission. g_Config.Load(); #endif + LogManager *logman = LogManager::GetInstance(); #if PPSSPP_PLATFORM(ANDROID) diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index a4a8852192..29afda806e 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -103,8 +103,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr