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 --- beos/beos_gui.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'beos/beos_gui.cpp') diff --git a/beos/beos_gui.cpp b/beos/beos_gui.cpp index 3f83a8dcb..6c05bc401 100644 --- a/beos/beos_gui.cpp +++ b/beos/beos_gui.cpp @@ -1160,3 +1160,23 @@ static void *myrealloc(void *ptr, size_t len, void *pw) { return realloc(ptr, len); } + +/** + * 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