From a2083b31e3692c97c3f74291d94b4fbb32a36cc6 Mon Sep 17 00:00:00 2001 From: oy Date: Thu, 16 Sep 2010 12:48:32 +0200 Subject: fixed last commit --- src/base/system.c | 15 +++++++-------- src/base/system.h | 8 +++++--- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'src/base') 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 -- cgit 1.4.1