Skip to content

Commit

Permalink
Use XDG base directories
Browse files Browse the repository at this point in the history
  • Loading branch information
ghisvail authored and Screwtapello committed Nov 10, 2020
1 parent fa21207 commit 2cf2ed6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions nall/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ inline auto userSettings() -> string {
#elif defined(PLATFORM_MACOS)
string result = {Path::user(), "Library/Application Support/"};
#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
if(!result) result = ".";
if(!result.endsWith("/")) result.append("/");
Expand All @@ -109,7 +114,12 @@ inline auto userData() -> string {
#elif defined(PLATFORM_MACOS)
string result = {Path::user(), "Library/Application Support/"};
#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
if(!result) result = ".";
if(!result.endsWith("/")) result.append("/");
Expand Down

0 comments on commit 2cf2ed6

Please sign in to comment.