changeset 500:1d81ea250dce trunk

[svn] - URIs are now passed naked instead of mangled by the VFS subsystem.
author nenolod
date Sun, 21 Jan 2007 20:51:22 -0800
parents ef7ceb6b183c
children 1b06f6690022
files ChangeLog src/curl/curl.c src/stdio/stdio.c
diffstat 3 files changed, 65 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jan 21 20:25:59 2007 -0800
+++ b/ChangeLog	Sun Jan 21 20:51:22 2007 -0800
@@ -1,3 +1,14 @@
+2007-01-22 04:25:59 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [1084]
+  - labotomize the ffmpeg I/O code, making it an over-engineered VFS 
+    wrapper (ouch!)
+  
+  trunk/src/wma/libffwma/allformats.c |    5 --
+  trunk/src/wma/libffwma/avio.c       |   26 ------------
+  trunk/src/wma/libffwma/file.c       |   77 ------------------------------------
+  3 files changed, 108 deletions(-)
+
+
 2007-01-22 04:09:18 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
   revision [1082]
   - ignore CURLE_PARTIAL_FILE, as this can happen in some cases and is 
--- a/src/curl/curl.c	Sun Jan 21 20:25:59 2007 -0800
+++ b/src/curl/curl.c	Sun Jan 21 20:51:22 2007 -0800
@@ -458,13 +458,13 @@
 curl_vfs_fopen_impl(const gchar * path,
 		    const gchar * mode)
 {
-  gchar *url = g_malloc(strlen(path) + strlen("http://") + 1);
+  gchar *url;
   CurlHandle *handle;
   VFSFile *file;
   if (!path || !mode)
     return NULL;
 
-  sprintf(url, "http://%s", path);
+  url = g_strdup(path);
 
   file = g_new0(VFSFile, 1);
 
--- a/src/stdio/stdio.c	Sun Jan 21 20:25:59 2007 -0800
+++ b/src/stdio/stdio.c	Sun Jan 21 20:51:22 2007 -0800
@@ -24,18 +24,69 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include <string.h>
+
+static gchar *
+vfs_stdio_urldecode_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;
+}
+
 VFSFile *
 stdio_vfs_fopen_impl(const gchar * path,
           const gchar * mode)
 {
     VFSFile *file;
+    gchar *decpath;
 
     if (!path || !mode)
 	return NULL;
 
+    decpath = vfs_stdio_urldecode_path(path);
+
     file = g_new(VFSFile, 1);
 
-    file->handle = fopen(path, mode);
+    file->handle = fopen(decpath != NULL ? decpath : path, mode);
+
+    if (decpath != NULL)
+        g_free(decpath);
 
     if (file->handle == NULL) {
         g_free(file);