Use XDG base directories

This commit is contained in:
Ghislain Antony Vaillant 2020-11-09 20:33:17 +01:00 committed by Screwtapello
parent d29677b778
commit 7a1d16bb3b
1 changed files with 12 additions and 2 deletions

View File

@ -90,7 +90,12 @@ inline auto userSettings() -> string {
#elif defined(PLATFORM_MACOS) #elif defined(PLATFORM_MACOS)
string result = {Path::user(), "Library/Application Support/"}; string result = {Path::user(), "Library/Application Support/"};
#else #else
string result = {Path::user(), ".config/"}; string result;
if(const char *env = getenv("XDG_CONFIG_HOME")) {
result = string(env);
} else {
result = {Path::user(), ".config/"};
}
#endif #endif
if(!result) result = "."; if(!result) result = ".";
if(!result.endsWith("/")) result.append("/"); if(!result.endsWith("/")) result.append("/");
@ -109,7 +114,12 @@ inline auto userData() -> string {
#elif defined(PLATFORM_MACOS) #elif defined(PLATFORM_MACOS)
string result = {Path::user(), "Library/Application Support/"}; string result = {Path::user(), "Library/Application Support/"};
#else #else
string result = {Path::user(), ".local/share/"}; string result;
if(const char *env = getenv("XDG_DATA_HOME")) {
result = string(env);
} else {
result = {Path::user(), ".local/share/"};
}
#endif #endif
if(!result) result = "."; if(!result) result = ".";
if(!result.endsWith("/")) result.append("/"); if(!result.endsWith("/")) result.append("/");