From c56642819eed87431dff3446fe111f7f3eefaa7d Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Wed, 7 May 2014 16:14:18 +0100 Subject: add file operations table and make all frontends use it. This rationalises the path construction and basename file operations. The default implementation is POSIX which works for all frontends except windows, riscos and amiga which have differeing path separators and rules. These implementations are significantly more robust than the previous nine implementations and also do not use unsafe strncpy or buffers with arbitrary length limits. These implementations also carry full documentation comments. --- framebuffer/fetch.c | 38 -------------------------------------- 1 file changed, 38 deletions(-) (limited to 'framebuffer/fetch.c') diff --git a/framebuffer/fetch.c b/framebuffer/fetch.c index c39ab5819..7c8dcc589 100644 --- a/framebuffer/fetch.c +++ b/framebuffer/fetch.c @@ -34,42 +34,6 @@ #include "framebuffer/findfile.h" #include "framebuffer/fetch.h" -/** - * Return the filename part of a full path - * - * \param path full path and filename - * \return filename (will be freed with free()) - */ -static char *filename_from_path(char *path) -{ - char *leafname; - - leafname = strrchr(path, '/'); - if (!leafname) - leafname = path; - else - leafname += 1; - - return strdup(leafname); -} - -/** - * Add a path component/filename to an existing path - * - * \param path buffer containing path + free space - * \param length length of buffer "path" - * \param newpart string containing path component to add to path - * \return true on success - */ -static bool path_add_part(char *path, int length, const char *newpart) -{ - if(path[strlen(path) - 1] != '/') - strncat(path, "/", length); - - strncat(path, newpart, length); - - return true; -} /** * Convert a pathname to a file: URL. @@ -183,8 +147,6 @@ static const char *fetch_filetype(const char *unix_path) /* table for fetch operations */ static struct gui_fetch_table fetch_table = { - .filename_from_path = filename_from_path, - .path_add_part = path_add_part, .filetype = fetch_filetype, .path_to_url = path_to_url, .url_to_path = url_to_path, -- cgit v1.2.3