diff options
author | t895 <clombardo169@gmail.com> | 2023-11-21 20:51:14 +0100 |
---|---|---|
committer | t895 <clombardo169@gmail.com> | 2023-11-21 20:53:32 +0100 |
commit | 14398a1cbb0377dde8afa97c1003acde835fc398 (patch) | |
tree | dc8cbdb9d29fdb98c98195f084ef2de85ddc2b9d /src | |
parent | frontend_common: Add special config case for unmapped windows network drives (diff) | |
download | yuzu-14398a1cbb0377dde8afa97c1003acde835fc398.tar yuzu-14398a1cbb0377dde8afa97c1003acde835fc398.tar.gz yuzu-14398a1cbb0377dde8afa97c1003acde835fc398.tar.bz2 yuzu-14398a1cbb0377dde8afa97c1003acde835fc398.tar.lz yuzu-14398a1cbb0377dde8afa97c1003acde835fc398.tar.xz yuzu-14398a1cbb0377dde8afa97c1003acde835fc398.tar.zst yuzu-14398a1cbb0377dde8afa97c1003acde835fc398.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/frontend_common/config.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/frontend_common/config.cpp b/src/frontend_common/config.cpp index b3f4a54a4..cf149ec26 100644 --- a/src/frontend_common/config.cpp +++ b/src/frontend_common/config.cpp @@ -16,6 +16,8 @@ #include <boost/algorithm/string/replace.hpp> +#include "common/string_util.h" + namespace FS = Common::FS; Config::Config(const ConfigType config_type) @@ -56,16 +58,43 @@ void Config::Initialize(const std::optional<std::string> config_path) { } void Config::WriteToIni() const { - if (const SI_Error rc = config->SaveFile(config_loc.c_str(), false); rc < 0) { + FILE* fp = nullptr; +#ifdef _WIN32 + fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb"); +#else + fp = fopen(config_loc.c_str(), "wb"); +#endif + + CSimpleIniA::FileWriter writer(fp); + const SI_Error rc = config->Save(writer, false); + if (rc < 0) { LOG_ERROR(Frontend, "Config file could not be saved!"); } + fclose(fp); } void Config::SetUpIni() { config = std::make_unique<CSimpleIniA>(); config->SetUnicode(true); config->SetSpaces(false); - config->LoadFile(config_loc.c_str()); + + FILE* fp = nullptr; +#ifdef _WIN32 + _wfopen_s(&fp, Common::UTF8ToUTF16W(config_loc).data(), L"rb, ccs=UTF-8"); + if (fp == nullptr) { + fp = _wfopen(Common::UTF8ToUTF16W(config_loc).data(), L"wb, ccs=UTF-8"); + } +#else + fp = fopen(config_loc.c_str(), "rb"); + if (fp == nullptr) { + fp = fopen(config_loc.c_str(), "wb"); + } +#endif + + if (SI_Error rc = config->LoadFile(fp); rc < 0) { + LOG_ERROR(Frontend, "Config file could not be loaded!"); + } + fclose(fp); } bool Config::IsCustomConfig() const { |