diff options
Diffstat (limited to 'src/base')
| -rw-r--r-- | src/base/system.c | 15 | ||||
| -rw-r--r-- | src/base/system.h | 8 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/base/system.c b/src/base/system.c index 9a291045..5312a705 100644 --- a/src/base/system.c +++ b/src/base/system.c @@ -984,18 +984,17 @@ int fs_chdir(const char *path) return 1; } -void fs_parent_dir(const char *path, char *buffer) +void fs_parent_dir(char *path) { - int stop = 0; - int i = 0; - for(i = 0; i < 256; i++) + char *parent = 0; + for(; *path; ++path) { - if(path[i] == '/') - stop = i+1; + if(*path == '/' || *path == '\\') + parent = path; } - //keep the chars which are before the last '/' and remove the chars which are after - str_copy(buffer, path, stop); + if(parent) + *parent = 0; } void swap_endian(void *data, unsigned elem_size, unsigned num) diff --git a/src/base/system.h b/src/base/system.h index c9d25260..e55e2ad7 100644 --- a/src/base/system.h +++ b/src/base/system.h @@ -949,10 +949,12 @@ int fs_chdir(const char *path); Get the parent directory of a directory Parameters: - path - The directory - buffer - Buffer to set the parent folder + path - The directory string + + Remarks: + - The string is treated as zero-termineted string. */ -void fs_parent_dir(const char *path, char *buffer); +void fs_parent_dir(char *path); /* Group: Undocumented |