changeset 207:75dbac8f2f59

Actually make th_get_config_dir() work.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 12 Feb 2016 02:47:11 +0200
parents c2193323736d
children 3635415a2d03
files th_file.c th_file.h
diffstat 2 files changed, 11 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/th_file.c	Fri Feb 12 00:16:49 2016 +0200
+++ b/th_file.c	Fri Feb 12 02:47:11 2016 +0200
@@ -41,23 +41,29 @@
 }
 
 
-char * th_get_config_dir()
+char * th_get_config_dir(const char *name)
 {
 #if defined(TH_PLAT_WINDOWS)
     // For Windows, we just use the appdata directory
+    (void) name;
     return th_get_data_dir();
 #elif defined(USE_XDG)
     const char *xdgConfigDir = getenv("XDG_CONFIG_HOME");
 
     // If XDG is enabled, try the environment variable first
     if (xdgConfigDir != NULL && strcmp(xdgConfigDir, ""))
-        return th_strdup_printf("%s" TH_DIR_SEPARATOR "%s" TH_DIR_SEPARATOR, xdgConfigDir, SET_XDG_CONFIG_DIR);
+        return th_strdup_printf("%s%c%s%c", xdgConfigDir, TH_DIR_SEPARATOR, name, TH_DIR_SEPARATOR);
     else
+    {
         // Nope, try the obvious alternative
-        return th_strdup_printf("%s" TH_DIR_SEPARATOR ".config" TH_DIR_SEPARATOR "%s" TH_DIR_SEPARATOR,
-            setHomeDir, SET_XDG_CONFIG_DIR);
+        char *data = th_get_data_dir();
+        char *dir = th_strdup_printf("%s%c%s%c%s%c", data, TH_DIR_SEPARATOR, ".config", TH_DIR_SEPARATOR, name, TH_DIR_SEPARATOR);
+        th_free(data);
+        return dir;
+    }
 #else
     // XDG not enabled
+    (void) name;
     return th_get_data_dir();
 #endif
 }
--- a/th_file.h	Fri Feb 12 00:16:49 2016 +0200
+++ b/th_file.h	Fri Feb 12 02:47:11 2016 +0200
@@ -35,7 +35,7 @@
 
 
 char *  th_get_home_dir();
-char *  th_get_config_dir();
+char *  th_get_config_dir(const char *name);
 
 BOOL    th_stat_path(const char *path, int *flags);
 BOOL    th_mkdir_path(const char *cpath, int mode);