Config: Cleanup Path usage for ini file load/save.

This commit is contained in:
Unknown W. Brackets 2022-12-17 08:44:40 -08:00
parent ba8e52d228
commit 5c9a38d50c
4 changed files with 12 additions and 12 deletions

View File

@ -67,13 +67,13 @@ std::shared_ptr<I18NCategory> I18NRepo::GetCategory(const char *category) {
}
}
std::string I18NRepo::GetIniPath(const std::string &languageID) const {
return "lang/" + languageID + ".ini";
Path I18NRepo::GetIniPath(const std::string &languageID) const {
return Path("lang") / (languageID + ".ini");
}
bool I18NRepo::IniExists(const std::string &languageID) const {
File::FileInfo info;
if (!VFSGetFileInfo(GetIniPath(languageID).c_str(), &info))
if (!VFSGetFileInfo(GetIniPath(languageID).ToString().c_str(), &info))
return false;
if (!info.exists)
return false;
@ -88,7 +88,7 @@ bool I18NRepo::LoadIni(const std::string &languageID, const Path &overridePath)
if (!overridePath.empty()) {
iniPath = overridePath / (languageID + ".ini");
} else {
iniPath = Path(GetIniPath(languageID));
iniPath = GetIniPath(languageID);
}
if (!ini.LoadFromVFS(iniPath.ToString()))

View File

@ -92,7 +92,7 @@ public:
std::map<std::string, std::vector<std::string>> GetMissingKeys() const;
private:
std::string GetIniPath(const std::string &languageID) const;
Path GetIniPath(const std::string &languageID) const;
void Clear();
I18NCategory *LoadSection(const Section *section, const char *name);
void SaveSection(IniFile &ini, Section *section, std::shared_ptr<I18NCategory> cat);

View File

@ -47,7 +47,7 @@ void Compatibility::Load(const std::string &gameID) {
IniFile compat2;
// This one is user-editable. Need to load it after the system one.
Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compat.ini";
if (compat2.Load(path.ToString())) {
if (compat2.Load(path)) {
CheckSettings(compat2, gameID);
}
}
@ -64,7 +64,7 @@ void Compatibility::Load(const std::string &gameID) {
IniFile compat2;
// This one is user-editable. Need to load it after the system one.
Path path = GetSysDirectory(DIRECTORY_SYSTEM) / "compatvr.ini";
if (compat2.Load(path.ToString())) {
if (compat2.Load(path)) {
CheckVRSettings(compat2, gameID);
}
}

View File

@ -1351,7 +1351,7 @@ void Config::Load(const char *iniFileName, const char *controllerIniFilename) {
bShowFrameProfiler = true;
IniFile iniFile;
if (!iniFile.Load(iniFilename_.ToString())) {
if (!iniFile.Load(iniFilename_)) {
ERROR_LOG(LOADER, "Failed to read '%s'. Setting config to default.", iniFilename_.c_str());
// Continue anyway to initialize the config.
}
@ -1879,7 +1879,7 @@ bool Config::saveGameConfig(const std::string &pGameId, const std::string &title
}
KeyMap::SaveToIni(iniFile);
iniFile.Save(fullIniFilePath.ToString());
iniFile.Save(fullIniFilePath);
return true;
}
@ -1894,7 +1894,7 @@ bool Config::loadGameConfig(const std::string &pGameId, const std::string &title
changeGameSpecific(pGameId, title);
IniFile iniFile;
iniFile.Load(iniFileNameFull.ToString());
iniFile.Load(iniFileNameFull);
auto postShaderSetting = iniFile.GetOrCreateSection("PostShaderSetting")->ToMap();
mPostShaderSetting.clear();
@ -1929,7 +1929,7 @@ void Config::unloadGameConfig() {
changeGameSpecific();
IniFile iniFile;
iniFile.Load(iniFilename_.ToString());
iniFile.Load(iniFilename_);
// Reload game specific settings back to standard.
IterateSettings(iniFile, [](Section *section, ConfigSetting *setting) {
@ -1957,7 +1957,7 @@ void Config::unloadGameConfig() {
void Config::LoadStandardControllerIni() {
IniFile controllerIniFile;
if (!controllerIniFile.Load(controllerIniFilename_.ToString())) {
if (!controllerIniFile.Load(controllerIniFilename_)) {
ERROR_LOG(LOADER, "Failed to read %s. Setting controller config to default.", controllerIniFilename_.c_str());
KeyMap::RestoreDefault();
} else {