diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-01-03 07:22:18 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-01-03 07:22:18 +0000 |
commit | b1cdf8dadf7487d81262f2c4ab76abb378648381 (patch) | |
tree | b2c64a188996587b886ce7ec67fff169c648cb04 /src/path.c | |
parent | b70912031d2dd899635c7b81fee82edb8047cfaa (diff) | |
download | mpd-b1cdf8dadf7487d81262f2c4ab76abb378648381.tar.gz mpd-b1cdf8dadf7487d81262f2c4ab76abb378648381.tar.xz mpd-b1cdf8dadf7487d81262f2c4ab76abb378648381.zip |
document parent_path()
git-svn-id: https://svn.musicpd.org/mpd/trunk@7128 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/path.c')
-rw-r--r-- | src/path.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/path.c b/src/path.c index 8c7b61cdf..a99f8bd2c 100644 --- a/src/path.c +++ b/src/path.c @@ -225,13 +225,23 @@ void pathcpy_trunc(char *dest, const char *src) char *parent_path(char *path_max_tmp, const char *path) { char *c; + static const int handle_trailing_slashes = 0; pathcpy_trunc(path_max_tmp, path); + + if (handle_trailing_slashes) { + size_t last_char = strlen(path_max_tmp) - 1; + + while (last_char > 0 && path_max_tmp[last_char] == '/') + path_max_tmp[last_char--] = '\0'; + } + c = strrchr(path_max_tmp,'/'); if (c == NULL) path_max_tmp[0] = '\0'; else { + /* strip redundant slashes: */ while ((path_max_tmp <= c) && *(--c) == '/') /* nothing */ ; c[1] = '\0'; |