summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/util.c b/util.c
index 4a5340b..59ece04 100644
--- a/util.c
+++ b/util.c
@@ -204,3 +204,13 @@ static void qsort_with_context(void *base, size_t nmemb, size_t size, int (*comp
qsort_ctx_cmp = compar;
qsort(base, nmemb, size, qsort_with_context_cmp);
}
+
+// the actual file name part of the path; get rid of the containing directory.
+// NOTE: the returned string is part of path, so you don't need to free it or anything.
+static char const *path_filename(char const *path) {
+ char const *last_path_sep = strrchr(path, PATH_SEPARATOR);
+ if (last_path_sep)
+ return last_path_sep + 1;
+ // (a relative path with no path separators)
+ return path;
+}