changeset 2665:3f931f933750

A tentative fix for adding XSPF playlists with relative file/pathnames. NOTICE!! Please test that this does not break anything else!
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 29 May 2008 02:35:19 +0300
parents 21c036700033
children 053341c248ef
files src/xspf/xspf.c
diffstat 1 files changed, 11 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/xspf/xspf.c	Wed May 28 22:21:54 2008 +0300
+++ b/src/xspf/xspf.c	Thu May 29 02:35:19 2008 +0300
@@ -134,8 +134,10 @@
             if (!xmlStrcmp(nptr->name, (xmlChar *)"location")) {
                 /* Location is a special case */
                 gchar *str = (gchar *)xmlNodeGetContent(nptr);
-
-                location = g_strdup_printf("%s%s", base ? base : "", str);
+                if (!strstr(str, "://") && base)
+                    location = g_strdup_printf("%s/%s", base, str);
+                else
+                    location = g_strdup(str);
                 xmlFree(str);
             } else {
                 /* Rest of the nodes are handled here */
@@ -260,7 +262,7 @@
             
             base = (gchar *)xmlNodeGetBase(doc, nptr);
 
-            AUDDBG("base = %s\n", base);
+            AUDDBG("base #1 = %s\n", base);
             
             // if filename is specified as a base, ignore it.
             tmp = xmlURIUnescapeString(base, -1, NULL);
@@ -272,7 +274,12 @@
                 g_free(tmp);
             }
             
-            AUDDBG("base = %s\n", base);
+            AUDDBG("base #2 = %s\n", base);
+            
+            if (!base)
+                base = g_path_get_dirname(filename);
+            
+            AUDDBG("base #3 = %s\n", base);
             
             for (nptr2 = nptr->children; nptr2 != NULL; nptr2 = nptr2->next) {