Core: Obey the XDG basedir specification for environment variables

This commit is contained in:
Emmanuel Gil Peyrot 2016-08-07 00:05:06 +01:00
parent 67a09eaa1d
commit 88fc68aaf7
1 changed files with 6 additions and 0 deletions

View File

@ -227,6 +227,12 @@ void mCoreConfigDirectory(char* out, size_t outLength) {
return;
}
char* xdgConfigHome = getenv("XDG_CONFIG_HOME");
if (xdgConfigHome && xdgConfigHome[0] == '/') {
snprintf(out, outLength, "%s/%s", xdgConfigHome, binaryName);
mkdir(out, 0755);
return;
}
char* home = getenv("HOME");
snprintf(out, outLength, "%s/.config", home);
mkdir(out, 0755);