Mercurial > hg > th-libs
diff th_file.c @ 740:caeb0a44ebdf
Change th_get_config_dir() API.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 14 Dec 2022 01:31:51 +0200 |
parents | 32dab9b6058a |
children | 0852bd106034 |
line wrap: on
line diff
--- a/th_file.c Wed Dec 14 01:31:25 2022 +0200 +++ b/th_file.c Wed Dec 14 01:31:51 2022 +0200 @@ -55,11 +55,10 @@ } -char * th_get_config_dir(const char *name) +char * th_get_config_dir(void) { #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"); @@ -67,24 +66,21 @@ // If XDG is enabled, try the environment variable first if (xdgConfigDir != NULL && strcmp(xdgConfigDir, "")) { - return th_strdup_printf("%s%c%s%c", - xdgConfigDir, TH_DIR_SEPARATOR_CHR, - name, TH_DIR_SEPARATOR_CHR); + return th_strdup_printf("%s%c", + xdgConfigDir, TH_DIR_SEPARATOR_CHR); } else { // Nope, try the obvious alternative char *data = th_get_data_dir(); - char *dir = th_strdup_printf("%s%c%s%c%s%c", + char *dir = th_strdup_printf("%s%c%s%c", data, TH_DIR_SEPARATOR_CHR, - ".config", TH_DIR_SEPARATOR_CHR, - name, TH_DIR_SEPARATOR_CHR); + ".config", TH_DIR_SEPARATOR_CHR); th_free(data); return dir; } #else // XDG not enabled - (void) name; return th_get_data_dir(); #endif }