mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-04 07:09:03 +00:00
commit
387e7ae1f3
2 changed files with 16 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <iostream>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
@ -317,12 +318,22 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data)
|
||||||
|
|
||||||
bool IniFile::Save(const std::string& filename)
|
bool IniFile::Save(const std::string& filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Create parent directories if they don't exist
|
||||||
|
std::filesystem::path path(filename);
|
||||||
|
std::filesystem::path parentPath = path.parent_path();
|
||||||
|
|
||||||
|
if (!exists(parentPath) && !create_directories(parentPath)) {
|
||||||
|
std::cerr << "Failed to create directory: " << parentPath << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
std::ofstream out;
|
std::ofstream out;
|
||||||
std::string temp = File::GetTempFilenameForAtomicWrite(filename);
|
std::string temp = File::GetTempFilenameForAtomicWrite(filename);
|
||||||
File::OpenFStream(out, temp, std::ios::out);
|
File::OpenFStream(out, temp, std::ios::out);
|
||||||
|
|
||||||
if (out.fail())
|
if (out.fail())
|
||||||
{
|
{
|
||||||
|
std::cerr << "Failed to open temporary file for writing: " << temp << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,11 @@ SConfig::SConfig()
|
||||||
LoadDefaults();
|
LoadDefaults();
|
||||||
// Make sure we have log manager
|
// Make sure we have log manager
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
|
|
||||||
|
// Check if config exists before saving
|
||||||
|
if (!File::Exists(File::GetUserPath(F_DOLPHINCONFIG_IDX))) {
|
||||||
|
SaveSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SConfig::Init()
|
void SConfig::Init()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue