Blob Blame History Raw
diff -uNr audacious-1.1.0-dr2-orig/audacious/main.c audacious-1.1.0-dr2/audacious/main.c
--- audacious-1.1.0-dr2-orig/audacious/main.c	2006-06-11 06:29:02.000000000 +0200
+++ audacious-1.1.0-dr2/audacious/main.c	2006-07-09 16:35:43.000000000 +0200
@@ -47,6 +47,10 @@
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 
+#ifdef HAVE_GNOME_VFS
+#include <libgnomevfs/gnome-vfs.h>
+#endif
+
 #include "libaudacious/configdb.h"
 #include "libaudacious/beepctrl.h"
 #include "libaudacious/util.h"
@@ -727,6 +731,47 @@
     exit(EXIT_SUCCESS);
 }
 
+static gchar*
+quote_filename(gchar* filename) {
+
+    /*
+     * Quote a filename for usage with gnome vfs.
+     * Since we get the filenames from the command line, we can
+     * not determine if they are already quoted or not.
+     *
+     * The algorithm employed here is as follows:
+     * - If the filename contains "://", it is treated as an URI
+     * - If the filename is an URI and contains "%" it is considered quoted.
+     * - If the filenname is not an URI, or an unquoted URI, it is quoted.
+     *
+     * This function does nothing if gnome VFS is not used.
+     */
+
+#ifdef HAVE_GNOME_VFS
+    gchar* quoted_filename;
+    char quote = 0;
+
+    if (strstr(filename, "://")) {
+        if (!strstr(filename, "%")) {
+            quote = 1;
+        }
+    } else {
+        quote = 1;
+    }
+
+    if (quote) {
+        gnome_vfs_init();
+        quoted_filename = gnome_vfs_escape_path_string(filename);
+        free(filename);
+        return quoted_filename;
+    } else {
+        return filename;
+    }
+#else
+    return filename;
+#endif
+}
+
 static void
 parse_cmd_line(gint argc,
                gchar ** argv,
@@ -820,6 +865,8 @@
         else
             filename = g_build_filename(current_dir, argv[i], NULL);
 
+        filename = quote_filename(filename);
+
         options->filenames = g_list_prepend(options->filenames, filename);
     }
 
diff -uNr audacious-1.1.0-dr2-orig/audacious/Makefile audacious-1.1.0-dr2/audacious/Makefile
--- audacious-1.1.0-dr2-orig/audacious/Makefile	2006-05-28 17:27:54.000000000 +0200
+++ audacious-1.1.0-dr2/audacious/Makefile	2006-07-09 16:53:21.000000000 +0200
@@ -18,6 +18,7 @@
 CFLAGS += \
 	$(GTK_CFLAGS)      \
 	$(LIBGLADE_CFLAGS) \
+	$(GNOMEVFS_CFLAGS) \
 	$(BEEP_DEFINES)    \
 	$(ARCH_DEFINES)    \
 	-I..    \
diff -uNr audacious-1.1.0-dr2-orig/libaudacious/vfs_gnome.c audacious-1.1.0-dr2/libaudacious/vfs_gnome.c
--- audacious-1.1.0-dr2-orig/libaudacious/vfs_gnome.c	2006-03-12 06:06:47.000000000 +0100
+++ audacious-1.1.0-dr2/libaudacious/vfs_gnome.c	2006-07-09 18:01:35.000000000 +0200
@@ -56,7 +56,7 @@
     file->eof = FALSE;
 
     mode_to_gnome_vfs(mode, &g_mode, &truncate, &append);
-    gchar *escaped_file = gnome_vfs_escape_path_string(path);
+    gchar *escaped_file = g_strdup(path);
 
     if (!truncate) {
         g_result = gnome_vfs_open(&(file->handle), escaped_file, g_mode);