summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtk_gui.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c
index 163972fc7..0251e173f 100644
--- a/gtk/gtk_gui.c
+++ b/gtk/gtk_gui.c
@@ -920,3 +920,23 @@ uint32_t gtk_gui_gdkkey_to_nskey(GdkEventKey *key)
key->keyval);
}
}
+
+/**
+ * Return the filename part of a full path
+ *
+ * \param path full path and filename
+ * \return filename (will be freed with free())
+ */
+
+char *filename_from_path(char *path)
+{
+ char *leafname;
+
+ leafname = strrchr(path, '/');
+ if (!leafname)
+ leafname = path;
+ else
+ leafname += 1;
+
+ return strdup(leafname);
+}