Add path_filename()

This commit is contained in:
Rodrigo Arias 2023-02-20 12:18:57 +01:00 committed by Rodrigo Arias Mallo
parent ce4552add5
commit 49743d4b9e
2 changed files with 13 additions and 0 deletions

View File

@ -100,3 +100,15 @@ path_remove_trailing(char *path)
path[i] = '\0';
}
}
const char *
path_filename(const char *path)
{
const char *start = strrchr(path, '/');
if (start == NULL)
start = path;
else
start++;
return start;
}

View File

@ -10,5 +10,6 @@ int path_next(const char *path, char sep, const char (**next));
int path_keep(char *path, int n);
int path_strip(const char *path, int n, const char (**next));
void path_remove_trailing(char *path);
const char *path_filename(const char *path);
#endif /* PATH_H */