From 033b5d815a19a05441a99cdc744a6a8752d191cc Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 21 Mar 2010 13:32:59 +0000 Subject: Move code which extracts the filename from a given path into frontend. svn path=/trunk/netsurf/; revision=10139 --- gtk/gtk_gui.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'gtk/gtk_gui.c') 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); +} -- cgit v1.2.3