From 6c19245ba7921e3b34b889e250dc603f1b585fdf Mon Sep 17 00:00:00 2001 From: camdenorrb Date: Sat, 14 Dec 2024 18:52:14 -0600 Subject: [PATCH 1/3] Save config --- Source/Core/Core/ConfigManager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index 21d722290e..fa792867b3 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -68,6 +68,11 @@ SConfig::SConfig() LoadDefaults(); // Make sure we have log manager LoadSettings(); + + // Check if config exists before saving + if (!File::Exists(File::GetUserPath(F_DOLPHINCONFIG_IDX))) { + Config::Save(); + } } void SConfig::Init() From 786f9e58bebd8586e9d60cc2c2742520f98ea3c7 Mon Sep 17 00:00:00 2001 From: camdenorrb Date: Sat, 14 Dec 2024 20:14:43 -0600 Subject: [PATCH 2/3] Save config --- Source/Core/Common/IniFile.cpp | 11 +++++++++++ Source/Core/Core/ConfigManager.cpp | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index b345f6c0fe..1b9a823e8e 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -317,12 +318,22 @@ bool IniFile::Load(const std::string& filename, bool keep_current_data) 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_directory(parentPath)) { + std::cerr << "Failed to create directory: " << parentPath << std::endl; + } + std::ofstream out; std::string temp = File::GetTempFilenameForAtomicWrite(filename); File::OpenFStream(out, temp, std::ios::out); if (out.fail()) { + std::cerr << "Failed to open temporary file for writing: " << temp << std::endl; return false; } diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index fa792867b3..4ad10edb73 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -71,7 +71,7 @@ SConfig::SConfig() // Check if config exists before saving if (!File::Exists(File::GetUserPath(F_DOLPHINCONFIG_IDX))) { - Config::Save(); + SaveSettings(); } } From 958ef14055fba04f738c55d8f4511821bef2fbe3 Mon Sep 17 00:00:00 2001 From: camdenorrb Date: Sat, 14 Dec 2024 20:18:49 -0600 Subject: [PATCH 3/3] Save config --- Source/Core/Common/IniFile.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/IniFile.cpp b/Source/Core/Common/IniFile.cpp index 1b9a823e8e..1fbb8cd6a6 100644 --- a/Source/Core/Common/IniFile.cpp +++ b/Source/Core/Common/IniFile.cpp @@ -323,7 +323,7 @@ bool IniFile::Save(const std::string& filename) std::filesystem::path path(filename); std::filesystem::path parentPath = path.parent_path(); - if (!exists(parentPath) && !create_directory(parentPath)) { + if (!exists(parentPath) && !create_directories(parentPath)) { std::cerr << "Failed to create directory: " << parentPath << std::endl; }