thigns
This commit is contained in:
parent
ab097e2370
commit
875b9c7dd1
5 changed files with 23 additions and 17 deletions
|
@ -1,12 +1,20 @@
|
|||
#include <fmt/core.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
fn Config::getInstance()->const Config& {
|
||||
using rfl::Result;
|
||||
|
||||
fn Config::getInstance()->Config {
|
||||
#ifdef __WIN32__
|
||||
const string path = string(getenv("LOCALAPPDATA")) + "\\draconis++\\config.toml";
|
||||
#else
|
||||
const string path = string(getenv("HOME")) + "/.config/draconis++/config.toml";
|
||||
#endif
|
||||
// ReSharper disable once CppDFAMemoryLeak
|
||||
static const Config* INSTANCE = new Config(rfl::toml::load<Config>(path).value());
|
||||
return *INSTANCE;
|
||||
}
|
||||
const Result<Config> result = rfl::toml::load<Config>(path);
|
||||
|
||||
if (result)
|
||||
return result.value();
|
||||
|
||||
fmt::println("Failed to load config file: {}", result.error().value().what());
|
||||
return {};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue