changeset 1398:13dd4f9bd4b4

pls: Write filename paths to disk, not URIs. Convert filename paths in PLS files to valid URIs.
author William Pitcock <nenolod@atheme-project.org>
date Fri, 03 Aug 2007 22:09:40 -0500
parents 6aaf2b06f056
children adb12b6703e6
files src/pls/pls.c
diffstat 1 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/pls/pls.c	Sat Aug 04 03:53:11 2007 +0200
+++ b/src/pls/pls.c	Fri Aug 03 22:09:40 2007 -0500
@@ -66,24 +66,31 @@
         g_snprintf(line_key, sizeof(line_key), "File%d", i);
         if ((line = read_ini_string(inifile, "playlist", line_key)))
         {
+            gchar *uri = g_filename_to_uri(line, NULL, NULL);
+
+            if (uri)
+                g_free(line);
+            else
+                uri = line;
+
             if (cfg.use_pl_metadata)
             {
                 g_snprintf(title_key, sizeof(title_key), "Title%d", i);
 
                 if ((title = read_ini_string(inifile, "playlist", title_key)))
-                    playlist_load_ins_file(playlist, line, filename, pos, title, -1);
+                    playlist_load_ins_file(playlist, uri, filename, pos, title, -1);
                 else
-                    playlist_load_ins_file(playlist, line, filename, pos, NULL, -1);
+                    playlist_load_ins_file(playlist, uri, filename, pos, NULL, -1);
             }
             else
-                playlist_load_ins_file(playlist, line, filename, pos, NULL, -1);
+                playlist_load_ins_file(playlist, uri, filename, pos, NULL, -1);
 
-                added_count++;
+            added_count++;
 
-                if (pos >= 0)
-                    pos++;
+            if (pos >= 0)
+                pos++;
 
-                g_free(line);
+            g_free(uri);
         }
     }
 
@@ -107,9 +114,17 @@
 
     for (node = playlist->entries; node; node = g_list_next(node)) {
         PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
+        gchar *fn;
+
+        if (vfs_is_remote(entry->filename))
+            fn = g_strdup(entry->filename);
+        else
+            fn = g_filename_from_uri(entry->filename, NULL, NULL);
 
         vfs_fprintf(file, "File%d=%s\n", g_list_position(playlist->entries, node) + 1,
-                    entry->filename);
+                    fn);
+
+        g_free(fn);
     }
 
     PLAYLIST_UNLOCK(playlist->mutex);