From fae7591b5399ca00b14917068494ca006f127bd0 Mon Sep 17 00:00:00 2001 From: Hyper <34012267+hyperbx@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:24:33 +0100 Subject: [PATCH] config: create user directory if it doesn't exist --- UnleashedRecomp/config.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/UnleashedRecomp/config.cpp b/UnleashedRecomp/config.cpp index 540ca7a..bf26b30 100644 --- a/UnleashedRecomp/config.cpp +++ b/UnleashedRecomp/config.cpp @@ -1,6 +1,8 @@ void Config::Load() { - if (!std::filesystem::exists(GetConfigPath())) + auto configPath = GetConfigPath(); + + if (!std::filesystem::exists(configPath)) { Config::Save(); return; @@ -8,7 +10,7 @@ void Config::Load() try { - auto toml = toml::parse_file(GetConfigPath().string()); + auto toml = toml::parse_file(configPath.string()); for (auto def : Definitions) def->ReadValue(toml); @@ -21,6 +23,11 @@ void Config::Load() void Config::Save() { + auto userPath = GetUserPath(); + + if (!std::filesystem::exists(userPath)) + std::filesystem::create_directory(userPath); + std::string result; std::string section;