# HG changeset patch # User nenolod # Date 1169441482 28800 # Node ID 1d81ea250dce36e8a50fb528d0755472523d7f9c # Parent ef7ceb6b183c9fe66c0b71b1654e946eec2e0079 [svn] - URIs are now passed naked instead of mangled by the VFS subsystem. diff -r ef7ceb6b183c -r 1d81ea250dce ChangeLog --- 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 + 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 revision [1082] - ignore CURLE_PARTIAL_FILE, as this can happen in some cases and is diff -r ef7ceb6b183c -r 1d81ea250dce src/curl/curl.c --- 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); diff -r ef7ceb6b183c -r 1d81ea250dce src/stdio/stdio.c --- 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 #include +#include + +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);