Skip to content

Commit

Permalink
Config: Cleanup Path usage for ini file load/save.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Dec 17, 2022
1 parent ba8e52d commit 5c9a38d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Common/Data/Text/I18n.cpp
Expand Up @@ -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;
Expand All @@ -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()))
Expand Down
2 changes: 1 addition & 1 deletion Common/Data/Text/I18n.h
Expand Up @@ -92,7 +92,7 @@ class I18NRepo {
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);
Expand Down
4 changes: 2 additions & 2 deletions Core/Compatibility.cpp
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down
10 changes: 5 additions & 5 deletions Core/Config.cpp
Expand Up @@ -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.
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 5c9a38d

Please sign in to comment.