Lines 128-136
Link Here
|
128 |
int sys_basename(char *result, const char *filename) |
128 |
int sys_basename(char *result, const char *filename) |
129 |
{ |
129 |
{ |
130 |
// FIXME: use is_path_delim |
130 |
// FIXME: use is_path_delim |
131 |
char *slash1 = strrchr(filename, '/'); |
131 |
const char *slash1 = strrchr(filename, '/'); |
132 |
char *slash2 = strrchr(filename, '\\'); |
132 |
const char *slash2 = strrchr(filename, '\\'); |
133 |
char *slash = (slash1 > slash2) ? slash1 : slash2; |
133 |
const char *slash = (slash1 > slash2) ? slash1 : slash2; |
134 |
if (slash) { |
134 |
if (slash) { |
135 |
int l = strlen(filename); |
135 |
int l = strlen(filename); |
136 |
ht_strlcpy(result, slash+1, l-(slash-filename)+1); |
136 |
ht_strlcpy(result, slash+1, l-(slash-filename)+1); |
Lines 143-151
Link Here
|
143 |
int sys_dirname(char *result, const char *filename) |
143 |
int sys_dirname(char *result, const char *filename) |
144 |
{ |
144 |
{ |
145 |
// FIXME: use is_path_delim |
145 |
// FIXME: use is_path_delim |
146 |
char *slash1 = strrchr(filename, '/'); |
146 |
const char *slash1 = strrchr(filename, '/'); |
147 |
char *slash2 = strrchr(filename, '\\'); |
147 |
const char *slash2 = strrchr(filename, '\\'); |
148 |
char *slash = (slash1 > slash2) ? slash1 : slash2; |
148 |
const char *slash = (slash1 > slash2) ? slash1 : slash2; |
149 |
if (slash) { |
149 |
if (slash) { |
150 |
ht_strlcpy(result, filename, slash-filename+1); |
150 |
ht_strlcpy(result, filename, slash-filename+1); |
151 |
return 0; |
151 |
return 0; |
Lines 263-276
Link Here
|
263 |
return (k == 0) ? 0 : EINVAL; |
263 |
return (k == 0) ? 0 : EINVAL; |
264 |
} |
264 |
} |
265 |
|
265 |
|
266 |
char *sys_filename_suffix(const char *fn) |
266 |
const char *sys_filename_suffix(const char *fn) |
267 |
{ |
267 |
{ |
268 |
const char *s = NULL; |
268 |
const char *s = NULL; |
269 |
while (fn && *fn) { |
269 |
while (fn && *fn) { |
270 |
if (sys_is_path_delim(*fn)) s = fn+1; |
270 |
if (sys_is_path_delim(*fn)) s = fn+1; |
271 |
fn++; |
271 |
fn++; |
272 |
} |
272 |
} |
273 |
char *p = s ? strrchr(s, '.') : NULL; |
273 |
const char *p = s ? strrchr(s, '.') : NULL; |
274 |
return p ? p+1 : NULL; |
274 |
return p ? p+1 : NULL; |
275 |
} |
275 |
} |
276 |
|
276 |
|