Mercurial > hg > th-libs
comparison th_file.c @ 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 | 3a852e9f70a6 |
children | 45c2e474a997 |
comparison
equal
deleted
inserted
replaced
556:46f0bea942e4 | 557:5c3697bfefa3 |
---|---|
64 #elif defined(USE_XDG) | 64 #elif defined(USE_XDG) |
65 const char *xdgConfigDir = getenv("XDG_CONFIG_HOME"); | 65 const char *xdgConfigDir = getenv("XDG_CONFIG_HOME"); |
66 | 66 |
67 // If XDG is enabled, try the environment variable first | 67 // If XDG is enabled, try the environment variable first |
68 if (xdgConfigDir != NULL && strcmp(xdgConfigDir, "")) | 68 if (xdgConfigDir != NULL && strcmp(xdgConfigDir, "")) |
69 return th_strdup_printf("%s%c%s%c", xdgConfigDir, TH_DIR_SEPARATOR, name, TH_DIR_SEPARATOR); | 69 { |
70 return th_strdup_printf("%s%c%s%c", | |
71 xdgConfigDir, TH_DIR_SEPARATOR_CHR, | |
72 name, TH_DIR_SEPARATOR_CHR); | |
73 } | |
70 else | 74 else |
71 { | 75 { |
72 // Nope, try the obvious alternative | 76 // Nope, try the obvious alternative |
73 char *data = th_get_data_dir(); | 77 char *data = th_get_data_dir(); |
74 char *dir = th_strdup_printf("%s%c%s%c%s%c", data, TH_DIR_SEPARATOR, ".config", TH_DIR_SEPARATOR, name, TH_DIR_SEPARATOR); | 78 char *dir = th_strdup_printf("%s%c%s%c%s%c", |
79 data, TH_DIR_SEPARATOR_CHR, | |
80 ".config", TH_DIR_SEPARATOR_CHR, | |
81 name, TH_DIR_SEPARATOR_CHR); | |
75 th_free(data); | 82 th_free(data); |
76 return dir; | 83 return dir; |
77 } | 84 } |
78 #else | 85 #else |
79 // XDG not enabled | 86 // XDG not enabled |
160 // Start creating the directory stucture | 167 // Start creating the directory stucture |
161 do | 168 do |
162 { | 169 { |
163 // Split foremost path element out | 170 // Split foremost path element out |
164 for (save = 0, end = start; path[end] != 0; end++) | 171 for (save = 0, end = start; path[end] != 0; end++) |
165 if (path[end] == TH_DIR_SEPARATOR) | 172 if (path[end] == TH_DIR_SEPARATOR_CHR) |
166 { | 173 { |
167 save = path[end]; | 174 save = path[end]; |
168 path[end] = 0; | 175 path[end] = 0; |
169 break; | 176 break; |
170 } | 177 } |