add ABADDON_CONFIG environment variable

This commit is contained in:
ouwou
2021-06-30 21:45:26 -04:00
parent f7ac0f2a1e
commit 4b089606ea
3 changed files with 21 additions and 2 deletions

View File

@@ -83,6 +83,9 @@ std::string Platform::FindResourceFolder() {
}
std::string Platform::FindConfigFile() {
const auto x = std::getenv("ABADDON_CONFIG");
if (x != nullptr)
return x;
return "./abaddon.ini";
}
@@ -103,6 +106,10 @@ std::string Platform::FindResourceFolder() {
}
std::string Platform::FindConfigFile() {
const auto x = std::getenv("ABADDON_CONFIG");
if (x != nullptr)
return x;
const auto home_path = std::string(std::getenv("HOME")) + "/.config/abaddon/abaddon.ini";
for (const auto path : { "./abaddon.ini"s, home_path }) {
if (IsFile(path)) return path;
@@ -117,6 +124,9 @@ std::string Platform::FindResourceFolder() {
}
std::string Platform::FindConfigFile() {
const auto x = std::getenv("ABADDON_CONFIG");
if (x != nullptr)
return x;
puts("unknown OS, trying to load config from cwd");
return "./abaddon.ini";
}