Mercurial > hg > th-libs
changeset 557:5c3697bfefa3
Rename TH_DIR_SEPARATOR define to TH_DIR_SEPARATOR_CHR and add new
TH_DIR_SEPARATOR_STR which defines an equal string constant.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 05 Jan 2020 10:45:33 +0200 |
parents | 46f0bea942e4 |
children | 7b7872212afd |
files | th_file.c th_file.h |
diffstat | 2 files changed, 14 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/th_file.c Sun Jan 05 10:44:58 2020 +0200 +++ b/th_file.c Sun Jan 05 10:45:33 2020 +0200 @@ -66,12 +66,19 @@ // 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, name, TH_DIR_SEPARATOR); + { + return th_strdup_printf("%s%c%s%c", + xdgConfigDir, TH_DIR_SEPARATOR_CHR, + name, 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", data, TH_DIR_SEPARATOR, ".config", TH_DIR_SEPARATOR, name, TH_DIR_SEPARATOR); + char *dir = th_strdup_printf("%s%c%s%c%s%c", + data, TH_DIR_SEPARATOR_CHR, + ".config", TH_DIR_SEPARATOR_CHR, + name, TH_DIR_SEPARATOR_CHR); th_free(data); return dir; } @@ -162,7 +169,7 @@ { // Split foremost path element out for (save = 0, end = start; path[end] != 0; end++) - if (path[end] == TH_DIR_SEPARATOR) + if (path[end] == TH_DIR_SEPARATOR_CHR) { save = path[end]; path[end] = 0;
--- a/th_file.h Sun Jan 05 10:44:58 2020 +0200 +++ b/th_file.h Sun Jan 05 10:45:33 2020 +0200 @@ -18,9 +18,11 @@ // Platform specific defines #if defined(TH_PLAT_WINDOWS) -# define TH_DIR_SEPARATOR '\\' +# define TH_DIR_SEPARATOR_CHR '\\' +# define TH_DIR_SEPARATOR_STR "\\" #else -# define TH_DIR_SEPARATOR '/' +# define TH_DIR_SEPARATOR_CHR '/' +# define TH_DIR_SEPARATOR_STR "/" #endif