mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-18 22:35:39 +00:00
INISettingsInterface: Fix saving/loading with Unicode paths
This commit is contained in:
parent
5b9db71b87
commit
ac42510780
|
@ -1,11 +1,19 @@
|
|||
#include "ini_settings_interface.h"
|
||||
#include "common/file_system.h"
|
||||
#include "common/log.h"
|
||||
#include <algorithm>
|
||||
Log_SetChannel(INISettingsInterface);
|
||||
|
||||
INISettingsInterface::INISettingsInterface(std::string filename) : m_filename(std::move(filename)), m_ini(true, true)
|
||||
{
|
||||
SI_Error err = m_ini.LoadFile(m_filename.c_str());
|
||||
SI_Error err = SI_FAIL;
|
||||
std::FILE* fp = FileSystem::OpenCFile(m_filename.c_str(), "rb");
|
||||
if (fp)
|
||||
{
|
||||
err = m_ini.LoadFile(fp);
|
||||
std::fclose(fp);
|
||||
}
|
||||
|
||||
if (err != SI_OK)
|
||||
Log_WarningPrintf("Settings could not be loaded from '%s', defaults will be used.", m_filename.c_str());
|
||||
}
|
||||
|
@ -18,7 +26,14 @@ INISettingsInterface::~INISettingsInterface()
|
|||
|
||||
bool INISettingsInterface::Save()
|
||||
{
|
||||
SI_Error err = m_ini.SaveFile(m_filename.c_str(), false);
|
||||
SI_Error err = SI_FAIL;
|
||||
std::FILE* fp = FileSystem::OpenCFile(m_filename.c_str(), "wb");
|
||||
if (fp)
|
||||
{
|
||||
err = m_ini.SaveFile(fp, false);
|
||||
std::fclose(fp);
|
||||
}
|
||||
|
||||
if (err != SI_OK)
|
||||
{
|
||||
Log_WarningPrintf("Failed to save settings to '%s'.", m_filename.c_str());
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
#pragma once
|
||||
#include "core/settings.h"
|
||||
|
||||
// being a pain here...
|
||||
#ifdef WIN32
|
||||
#include "common/windows_headers.h"
|
||||
#endif
|
||||
#include "SimpleIni.h"
|
||||
|
||||
class INISettingsInterface : public SettingsInterface
|
||||
|
|
Loading…
Reference in a new issue