summaryrefslogtreecommitdiffstats
path: root/src/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index 068f2dd..0ad775c 100644
--- a/src/common.c
+++ b/src/common.c
@@ -695,3 +695,20 @@ int _plist_dict_copy_item(plist_t target_dict, plist_t source_dict, const char *
plist_dict_set_item(target_dict, key, plist_copy(node));
return 0;
}
+
+char* path_get_basename(char* path)
+{
+#ifdef WIN32
+ char *p = path + strlen(path);
+ while (p > path) {
+ if ((*p == '/') || (*p == '\\')) {
+ return p+1;
+ }
+ p--;
+ }
+ return p;
+#else
+ char *p = strrchr(path, '/');
+ return p ? p + 1 : path;
+#endif
+}