changeset 2978:f4971c7d6384 trunk

Remove inlined urldecoding functions and use g_filename_from_uri() instead where appropriate.
author William Pitcock <nenolod@atheme-project.org>
date Tue, 03 Jul 2007 21:20:01 -0500
parents 54081d5cbd76
children 2d91fa378e45
files src/audacious/playlist.c src/audacious/vfs.c
diffstat 2 files changed, 2 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/playlist.c	Tue Jul 03 19:45:35 2007 -0500
+++ b/src/audacious/playlist.c	Tue Jul 03 21:20:01 2007 -0500
@@ -897,49 +897,6 @@
     return playlist_ins_url(playlist, url, -1);
 }
 
-static gchar *
-_playlist_urldecode_basic_path(const gchar * encoded_path)
-{
-    const gchar *cur, *ext;
-    gchar *path, *tmp;
-    gint realchar;
-
-    if (!encoded_path)
-        return NULL;
-
-    if (!str_has_prefix_nocase(encoded_path, "file:"))
-        return NULL;
-
-    cur = encoded_path + 5;
-
-    if (str_has_prefix_nocase(cur, "//localhost"))
-        cur += 11;
-
-    if (*cur == '/')
-        while (cur[1] == '/')
-            cur++;
-
-    tmp = g_malloc0(strlen(cur) + 1);
-
-    while ((ext = strchr(cur, '%')) != NULL) {
-        strncat(tmp, cur, ext - cur);
-        ext++;
-        cur = ext + 2;
-        if (!sscanf(ext, "%2x", &realchar)) {
-            /* Assume it is a literal '%'.  Several file
-             * managers send unencoded file: urls on drag
-             * and drop. */
-            realchar = '%';
-            cur -= 2;
-        }
-        tmp[strlen(tmp)] = realchar;
-    }
-
-    path = g_strconcat(tmp, cur, NULL);
-    g_free(tmp);
-    return path;
-}
-
 guint
 playlist_ins_dir(Playlist * playlist, const gchar * path,
                     gint pos,
@@ -948,7 +905,7 @@
     guint entries = 0;
     GList *list, *node;
     GHashTable *htab;
-    gchar *path2 = _playlist_urldecode_basic_path(path);
+    gchar *path2 = g_filename_from_uri(path, NULL, NULL);
 
     if (path2 == NULL)
         path2 = g_strdup(path);
--- a/src/audacious/vfs.c	Tue Jul 03 19:45:35 2007 -0500
+++ b/src/audacious/vfs.c	Tue Jul 03 21:20:01 2007 -0500
@@ -339,49 +339,6 @@
     return NULL;
 }
 
-static gchar *
-_vfs_urldecode_basic_path(const gchar * encoded_path)
-{
-    const gchar *cur, *ext;
-    gchar *path, *tmp;
-    gint realchar;
-
-    if (!encoded_path)
-        return NULL;
-
-    if (!str_has_prefix_nocase(encoded_path, "file:"))
-        return NULL;
-
-    cur = encoded_path + 5;
-
-    if (str_has_prefix_nocase(cur, "//localhost"))
-        cur += 11;
-
-    if (*cur == '/')
-        while (cur[1] == '/')
-            cur++;
-
-    tmp = g_malloc0(strlen(cur) + 1);
-
-    while ((ext = strchr(cur, '%')) != NULL) {
-        strncat(tmp, cur, ext - cur);
-        ext++;
-        cur = ext + 2;
-        if (!sscanf(ext, "%2x", &realchar)) {
-            /* Assume it is a literal '%'.  Several file
-             * managers send unencoded file: urls on drag
-             * and drop. */
-            realchar = '%';
-            cur -= 2;
-        }
-        tmp[strlen(tmp)] = realchar;
-    }
-
-    path = g_strconcat(tmp, cur, NULL);
-    g_free(tmp);
-    return path;
-}
-
 /**
  * vfs_file_test:
  * @path: A path to test.
@@ -397,7 +354,7 @@
     gchar *path2;
     gboolean ret;
 
-    path2 = _vfs_urldecode_basic_path(path);
+    path2 = g_filename_from_uri(path, NULL, NULL);
 
     if (path2 == NULL)
         path2 = g_strdup(path);