Mercurial > hg > th-libs
changeset 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 |
files | th_file.c th_file.h |
diffstat | 2 files changed, 6 insertions(+), 10 deletions(-) [+] |
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 }
--- a/th_file.h Wed Dec 14 01:31:25 2022 +0200 +++ b/th_file.h Wed Dec 14 01:31:51 2022 +0200 @@ -46,7 +46,7 @@ char * th_get_home_dir(void); -char * th_get_config_dir(const char *name); +char * th_get_config_dir(void); bool th_stat_path(const char *path, th_stat_data *data); bool th_mkdir_path(const char *path, const int mode);