osme stuf

This commit is contained in:
Mars 2024-07-02 05:54:06 -04:00
parent 4f039f9c79
commit dff976ed0e
7 changed files with 44 additions and 48 deletions

View file

@ -4,12 +4,18 @@
using rfl::Result;
fn Config::getInstance() -> Config {
inline fn GetConfigPath() -> string {
return getenv(
#ifdef __WIN32__
const string path = string(getenv("LOCALAPPDATA")) + "\\draconis++\\config.toml";
"LOCALAPPDATA"
#else
const string path = string(getenv("HOME")) + "/.config/draconis++/config.toml";
"HOME"
#endif
);
}
fn Config::getInstance() -> Config {
const string path = GetConfigPath() + "\\draconis++\\config.toml";
const Result<Config> result = rfl::toml::load<Config>(path);
if (result)
@ -18,4 +24,3 @@ fn Config::getInstance() -> Config {
fmt::println("Failed to load config file: {}", result.error().value().what());
return {};
}