Remove the ability to have multiple search paths for config.

This commit is contained in:
Henrik Rydgård 2021-05-30 12:45:12 +02:00
parent 72915f88c8
commit 239838b6c3
5 changed files with 16 additions and 32 deletions

View File

@ -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;
}

View File

@ -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<Path> searchPath_;
Path defaultPath_;
Path searchPath_;
};
std::map<std::string, std::pair<std::string, int>> GetLangValuesMapping();

View File

@ -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)

View File

@ -103,8 +103,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
// Load config up here, because those changes below would be overwritten
// if it's not loaded here first.
g_Config.AddSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
g_Config.SetDefaultPath(GetSysDirectory(DIRECTORY_SYSTEM));
g_Config.SetSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
g_Config.Load();
bool debugLogLevel = false;

View File

@ -583,8 +583,7 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin
// Load config up here, because those changes below would be overwritten
// if it's not loaded here first.
g_Config.AddSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
g_Config.SetDefaultPath(GetSysDirectory(DIRECTORY_SYSTEM));
g_Config.SetSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
g_Config.Load(configFilename.c_str(), controlsConfigFilename.c_str());
bool debugLogLevel = false;