changeset 1252:551f76613eb2

Fix m3u loading for real.
author William Pitcock <nenolod@atheme-project.org>
date Fri, 13 Jul 2007 04:17:37 -0500
parents 9addc8bc98d6
children 5cdda0e144ab 9de798e20cb3
files src/m3u/m3u.c
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/m3u/m3u.c	Fri Jul 13 03:01:57 2007 +0100
+++ b/src/m3u/m3u.c	Fri Jul 13 04:17:37 2007 -0500
@@ -85,10 +85,16 @@
     gint ext_len = -1;
     gboolean is_extm3u = FALSE;
     Playlist *playlist = playlist_get_active();
+    gchar *uri;
+    
+    uri = g_filename_to_uri(filename, NULL, NULL);
 
-    if ((file = vfs_fopen(filename, "rb")) == NULL)
+    if ((file = vfs_fopen(uri ? uri : filename, "rb")) == NULL)
         return;
 
+    if (uri)
+        g_free(uri);
+
     line = g_malloc(line_len);
     while (vfs_fgets(line, line_len, file)) {
         while (strlen(line) == line_len - 1 && line[strlen(line) - 1] != '\n') {
@@ -126,7 +132,11 @@
             ext_info = NULL;
         }
 
-        playlist_load_ins_file(playlist, line, filename, pos, ext_title, ext_len);
+        uri = g_filename_to_uri(line, NULL, NULL);
+        playlist_load_ins_file(playlist, uri ? uri : line, filename, pos, ext_title, ext_len);
+
+        if (uri)
+            g_free(uri);
 
         str_replace_in(&ext_title, NULL);
         ext_len = -1;
@@ -146,6 +156,7 @@
     gchar *outstr = NULL;
     VFSFile *file;
     Playlist *playlist = playlist_get_active();
+    gchar *fn;
 
     g_return_if_fail(filename != NULL);
     g_return_if_fail(playlist != NULL);
@@ -180,7 +191,11 @@
             }
         }
 
-        vfs_fprintf(file, "%s\n", entry->filename);
+        fn = g_filename_from_uri(entry->filename, NULL, NULL);
+        vfs_fprintf(file, "%s\n", fn ? fn : entry->filename);
+
+        if (fn)
+            g_free(fn);
     }
 
     PLAYLIST_UNLOCK(playlist->mutex);