emu_settings: fix faulty custom config file creation

This commit is contained in:
Megamouse 2017-08-12 11:12:21 +02:00 committed by Ivan
parent 4c42043940
commit eeb4d4d4de
2 changed files with 11 additions and 3 deletions

View File

@ -174,6 +174,8 @@ Render_Creator::Render_Creator()
emu_settings::emu_settings(const std::string& path) : QObject()
{
m_path = path;
// Create config path if necessary
fs::create_path(fs::get_config_dir() + path);
@ -185,9 +187,9 @@ emu_settings::emu_settings(const std::string& path) : QObject()
currentSettings += YAML::Load(config.to_string());
// Add game config
if (!path.empty())
if (!path.empty() && fs::is_file(fs::get_config_dir() + path + "/config.yml"))
{
config = fs::file(fs::get_config_dir() + path + "/config.yml", fs::read + fs::write + fs::create);
config = fs::file(fs::get_config_dir() + path + "/config.yml", fs::read + fs::write);
currentSettings += YAML::Load(config.to_string());
}
}
@ -200,7 +202,12 @@ void emu_settings::SaveSettings()
{
YAML::Emitter out;
emitData(out, currentSettings);
if (!m_path.empty())
{
config = fs::file(fs::get_config_dir() + m_path + "/config.yml", fs::read + fs::write + fs::create);
}
// Save config
config.seek(0);
config.trunc(0);

View File

@ -205,4 +205,5 @@ private:
YAML::Node currentSettings; // The current settings as a YAML node.
fs::file config; //! File to read/write the config settings.
std::string m_path;
};