changeset 4877:ab60d53dd965

Use g_filename_to_uri on command line items that do not contain "://" (bug #51)
author John Lindgren <john.lindgren@tds.net>
date Fri, 01 May 2009 19:35:44 -0400
parents 85e71772af79
children a3cf163c772b
files src/audlegacy/main.c
diffstat 1 files changed, 15 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/audlegacy/main.c	Tue Apr 28 23:00:58 2009 +0100
+++ b/src/audlegacy/main.c	Fri May 01 19:35:44 2009 -0400
@@ -249,6 +249,7 @@
 static void
 handle_cmd_line_filenames(gboolean is_running)
 {
+  char * working, * absolute, * uri;
     gchar **filenames = options.filenames;
 #ifdef USE_DBUS
     DBusGProxy *session = audacious_get_dbus_proxy();
@@ -261,28 +262,21 @@
     gint i = 0;
     GList *fns = NULL;
 
-    for (i = 0; filenames[i] != NULL; i++)
-    {
-        gchar *filename;
-        gchar *current_dir = g_get_current_dir();
-
-        if (!strstr(filenames[i], "://"))
-        {
-            if (filenames[i][0] == '/')
-                filename = g_strdup_printf("file:///%s", filenames[i]);
-            else
-                filename = g_strdup_printf("file:///%s/%s", current_dir,
-                                           filenames[i]);
-        }
-        else
-            filename = g_strdup(filenames[i]);
-
-        fns = g_list_prepend(fns, filename);
-
-        g_free(current_dir);
+    working = g_get_current_dir ();
+    for (i = 0; filenames [i]; i ++) {
+       if (strstr (filenames [i], "://"))
+          uri = g_strdup (filenames [i]);
+       else if (filenames [i] [0] == '/')
+          uri = g_filename_to_uri (filenames [i], 0, 0);
+       else {
+          absolute = g_strdup_printf ("/%s/%s", working, filenames [i]);
+          uri = g_filename_to_uri (absolute, 0, 0);
+          g_free (absolute);
+       }
+       fns = g_list_prepend (fns, uri);
     }
-
-    fns = g_list_reverse(fns);
+    fns = g_list_reverse (fns);
+    g_free (working);
 
 #ifdef USE_DBUS
     if (is_running)