]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Use ~/.config on linux for root directory if legacy path not found TimePath/issue-16
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 6 Dec 2014 05:51:06 +0000 (16:51 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 6 Dec 2014 06:01:31 +0000 (17:01 +1100)
fs.c

diff --git a/fs.c b/fs.c
index 994155aa290fe5ad69bb3b05e7531ae28995b64d..00a4aa310b9b9f54e0a3279384b794e179645486 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1847,7 +1847,19 @@ static int FS_ChooseUserDir(userdirmode_t userdirmode, char *userdir, size_t use
                homedir = getenv("HOME");
                if(homedir)
                {
+#ifdef MACOSX
                        dpsnprintf(userdir, userdirsize, "%s/.%s/", homedir, gameuserdirname);
+#else
+                       // Legacy ~/.userdir location
+                       if(access(va(vabuf, sizeof(vabuf), "%s/.%s/", homedir, gameuserdirname), W_OK | X_OK) >= 0)
+                       {
+                               dpsnprintf(userdir, userdirsize, "%s/.%s/", homedir, gameuserdirname);
+                               break;
+                       }
+                       // XDG_CONFIG_HOME
+                       strlcat(homedir, "/.config", sizeof(homedir));
+                       dpsnprintf(userdir, userdirsize, "%s/.config/%s/", homedir, gameuserdirname);
+#endif
                        break;
                }
                return -1;