From: Sergey Poznyakoff Date: Thu, 4 Sep 2003 15:47:26 +0000 (+0000) Subject: (cut_path_elements): New functon. X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=3590887776356e895863847e3b58d6a2962009c6;p=chaz%2Ftar (cut_path_elements): New functon. --- diff --git a/src/names.c b/src/names.c index 8301a3e..ee68749 100644 --- a/src/names.c +++ b/src/names.c @@ -1043,6 +1043,23 @@ safer_name_suffix (char const *file_name, bool link_target) return (char *) p; } +char const * +cut_path_elements (char const *file_name, size_t num) +{ + char const *p = file_name; + if (ISSLASH (*p)) + p++; + for (; *p; p++) + { + if (ISSLASH (*p)) + { + if (--num == 0) + return p + 1; + } + } + return NULL; +} + /* Return nonzero if NAME contains ".." as a path name component. */ bool contains_dot_dot (char const *name)