forked from len0rd/rockbox
pathfuncs.c remove strip_leading_separators()
This should actually be strip_extra_leading_separators() but its not used anywhere else yet and I don't see enough callers in core to make it worth the extra overhead Change-Id: Icdd292869b4198bed7725c51820f6b2111ad739d
This commit is contained in:
parent
ae25a425b6
commit
7b12cc3927
2 changed files with 4 additions and 20 deletions
|
@ -339,23 +339,6 @@ size_t path_dirname(const char *name, const char **nameptr)
|
||||||
return q - name;
|
return q - name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Removes leading separators from a path
|
|
||||||
* "" *nameptr->NUL, count=0: ""
|
|
||||||
* "/" *nameptr->/, count=1: "/"
|
|
||||||
* "//" *nameptr->2nd /, count=2: "/"
|
|
||||||
* "a/" *nameptr->a/, count=0: "a/"
|
|
||||||
* "//b//" *nameptr->2nd /, count=2: "/b//"
|
|
||||||
* "/c/" *nameptr->/, count=1: "/c/"
|
|
||||||
*/
|
|
||||||
size_t path_strip_leading_separators(const char *name, const char **nameptr)
|
|
||||||
{
|
|
||||||
const char *p = name;
|
|
||||||
*nameptr = p;
|
|
||||||
while (*(p) == PATH_SEPCH && *(++p) == PATH_SEPCH)
|
|
||||||
*nameptr = p;
|
|
||||||
return p - name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Removes trailing separators from a path
|
/* Removes trailing separators from a path
|
||||||
* "" *nameptr->NUL, len=0: ""
|
* "" *nameptr->NUL, len=0: ""
|
||||||
* "/" *nameptr->/, len=1: "/"
|
* "/" *nameptr->/, len=1: "/"
|
||||||
|
@ -503,9 +486,11 @@ size_t path_append_ex(char *buf, const char *basepath, size_t basepath_max,
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
else if (basepath)
|
else if (basepath)
|
||||||
{
|
{
|
||||||
path_strip_leading_separators(basepath, &basepath);
|
/* strip extra leading separators */
|
||||||
|
while (*basepath == PATH_SEPCH && *(basepath + 1) == PATH_SEPCH)
|
||||||
|
basepath++;
|
||||||
len = strlcpy(buf, basepath, bufsize);
|
len = strlcpy(buf, basepath, bufsize);
|
||||||
if (basepath_max < len)
|
if (basepath_max < len) /*if needed truncate basepath to basepath_max */
|
||||||
{
|
{
|
||||||
len = basepath_max;
|
len = basepath_max;
|
||||||
buf[basepath_max] = '\0';
|
buf[basepath_max] = '\0';
|
||||||
|
|
|
@ -87,7 +87,6 @@ int make_volume_root(int volume, char *dst);
|
||||||
int path_strip_drive(const char *name, const char **nameptr, bool greedy);
|
int path_strip_drive(const char *name, const char **nameptr, bool greedy);
|
||||||
size_t path_basename(const char *name, const char **nameptr);
|
size_t path_basename(const char *name, const char **nameptr);
|
||||||
size_t path_dirname(const char *name, const char **nameptr);
|
size_t path_dirname(const char *name, const char **nameptr);
|
||||||
size_t path_strip_leading_separators(const char *name, const char **nameptr);
|
|
||||||
size_t path_strip_trailing_separators(const char *name, const char **nameptr);
|
size_t path_strip_trailing_separators(const char *name, const char **nameptr);
|
||||||
void path_correct_separators(char *dstpath, const char *path);
|
void path_correct_separators(char *dstpath, const char *path);
|
||||||
void path_remove_dot_segments(char *dstpath, const char *path);
|
void path_remove_dot_segments(char *dstpath, const char *path);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue