This commit is contained in:
Mars 2025-02-16 22:43:04 -05:00
parent 95374d942d
commit f9a9491da3
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895
9 changed files with 141 additions and 103 deletions

View file

@ -8,22 +8,24 @@
using rfl::Result;
namespace fs = std::filesystem;
inline fn GetConfigPath() -> fs::path {
namespace {
inline fn GetConfigPath() -> fs::path {
#ifdef _WIN32
const char* localAppData = std::getenv("LOCALAPPDATA");
const char* localAppData = std::getenv("LOCALAPPDATA");
if (!localAppData)
throw std::runtime_error("Environment variable LOCALAPPDATA is not set");
if (!localAppData)
throw std::runtime_error("Environment variable LOCALAPPDATA is not set");
return fs::path(localAppData);
return fs::path(localAppData);
#else
const char* home = std::getenv("HOME");
const char* home = std::getenv("HOME");
if (!home)
throw std::runtime_error("Environment variable HOME is not set");
if (!home)
throw std::runtime_error("Environment variable HOME is not set");
return fs::path(home) / ".config";
return fs::path(home) / ".config";
#endif
}
}
fn Config::getInstance() -> Config {