From 7a1d16bb3b56bd300466281f1f7edd3d0a8b90fe Mon Sep 17 00:00:00 2001 From: Ghislain Antony Vaillant Date: Mon, 9 Nov 2020 20:33:17 +0100 Subject: [PATCH] Use XDG base directories --- nall/path.hpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nall/path.hpp b/nall/path.hpp index 5506f7f0..3353817b 100644 --- a/nall/path.hpp +++ b/nall/path.hpp @@ -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("/"); @@ -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("/");