diff options
| author | oy <Tom_Adams@web.de> | 2010-09-16 12:48:32 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2010-09-16 12:48:32 +0200 |
| commit | a2083b31e3692c97c3f74291d94b4fbb32a36cc6 (patch) | |
| tree | d8348cb53203a8c5d02f0c4b099e77bd43bac1fe /src/base | |
| parent | 582763bc2148138e7da310268b58fdde4e6a6c43 (diff) | |
| download | zcatch-a2083b31e3692c97c3f74291d94b4fbb32a36cc6.tar.gz zcatch-a2083b31e3692c97c3f74291d94b4fbb32a36cc6.zip | |
fixed last commit
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 |