diff options
author | Martin Pärtel <martin.partel@gmail.com> | 2012-09-14 16:59:49 +0300 |
---|---|---|
committer | Martin Pärtel <martin.partel@gmail.com> | 2012-09-14 16:59:49 +0300 |
commit | f6161698827488cc21f3f3726d5af0cb2a89ce4b (patch) | |
tree | b7ebdfdfe8f9a70905a0878415e768f66200d953 /src/misc.h | |
parent | 66f00111c4e886e244152e460ada62164c975d4d (diff) | |
download | bindfs-f6161698827488cc21f3f3726d5af0cb2a89ce4b.tar.gz |
Implemented my_dirname and added unit tests for it.
Diffstat (limited to 'src/misc.h')
-rw-r--r-- | src/misc.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -38,6 +38,14 @@ char *strdup_until(const char *s, const char *endchars); Returns NULL if path is NULL. */ const char *my_basename(const char *path); +/* A thread-safe version of dirname, with slightly different behavior. + If path is ".", returns "..". + If path is "/", returns "/". + If path has an initial slash but no other slashes, returns "/". + If path contains a slash, replaces the last slash with a '\0' and returns path. + Otherwise, returns ".". */ +const char *my_dirname(char *path); + /* Reallocs `*array` (may be NULL) to be at least one larger than `*capacity` (may be 0) and stores the new capacity in `*capacity`. */ |