mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-10-30 07:11:05 +00:00
config: create user directory if it doesn't exist
This commit is contained in:
parent
efaf8fb8c4
commit
fae7591b53
1 changed files with 9 additions and 2 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
void Config::Load()
|
void Config::Load()
|
||||||
{
|
{
|
||||||
if (!std::filesystem::exists(GetConfigPath()))
|
auto configPath = GetConfigPath();
|
||||||
|
|
||||||
|
if (!std::filesystem::exists(configPath))
|
||||||
{
|
{
|
||||||
Config::Save();
|
Config::Save();
|
||||||
return;
|
return;
|
||||||
|
|
@ -8,7 +10,7 @@ void Config::Load()
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
auto toml = toml::parse_file(GetConfigPath().string());
|
auto toml = toml::parse_file(configPath.string());
|
||||||
|
|
||||||
for (auto def : Definitions)
|
for (auto def : Definitions)
|
||||||
def->ReadValue(toml);
|
def->ReadValue(toml);
|
||||||
|
|
@ -21,6 +23,11 @@ void Config::Load()
|
||||||
|
|
||||||
void Config::Save()
|
void Config::Save()
|
||||||
{
|
{
|
||||||
|
auto userPath = GetUserPath();
|
||||||
|
|
||||||
|
if (!std::filesystem::exists(userPath))
|
||||||
|
std::filesystem::create_directory(userPath);
|
||||||
|
|
||||||
std::string result;
|
std::string result;
|
||||||
std::string section;
|
std::string section;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue