]> git.sesse.net Git - vlc/commitdiff
playlist_MLLoad: format library URI correctly
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 23 Jun 2009 19:13:24 +0000 (22:13 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 23 Jun 2009 19:13:24 +0000 (22:13 +0300)
src/playlist/loadsave.c

index 5de646a658e0a730d5d44c8164fb93553780ad03..80abaada435210ec905c84d0d0b90da6dccf51e7 100644 (file)
@@ -130,34 +130,39 @@ int playlist_MLLoad( playlist_t *p_playlist )
         return VLC_EGENERIC;
     }
 
-    if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xspf", psz_datadir ) == -1 )
-    {
-        psz_uri = NULL;
-        goto error;
+    if( asprintf( &psz_uri, "%s" DIR_SEP "ml.xspf", psz_datadir ) != -1 )
+    {   /* loosy check for media library file */
+        struct stat st;
+        int ret = utf8_stat( psz_uri , &st );
+        free( psz_uri );
+        if( ret )
+        {
+            free( psz_datadir );
+            return VLC_EGENERIC;
+        }
     }
-    struct stat p_stat;
-    /* checks if media library file is present */
-    if( utf8_stat( psz_uri , &p_stat ) )
-        goto error;
-    free( psz_uri );
 
-    /* FIXME: WTF? stat() should never be used right before open()! */
-    if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP "ml.xspf",
-                  psz_datadir ) == -1 )
-    {
+    psz_uri = make_URI( psz_datadir );
+    free( psz_datadir );
+    psz_datadir = psz_uri;
+    if( psz_datadir == NULL )
+        return VLC_EGENERIC;
+
+    if( asprintf( &psz_uri, "%s/ml.xspf", psz_datadir ) == -1 )
         psz_uri = NULL;
-        goto error;
-    }
     free( psz_datadir );
     psz_datadir = NULL;
+    if( psz_uri == NULL )
+        return VLC_ENOMEM;
 
-    const char *const psz_option = "meta-file";
+    const char *const options[] = { "meta-file", "demux=xspf-open" };
     /* that option has to be cleaned in input_item_subitem_added() */
     /* vlc_gc_decref() in the same function */
     p_input = input_item_NewExt( p_playlist, psz_uri, _("Media Library"),
-                                 1, &psz_option, VLC_INPUT_OPTION_TRUSTED, -1 );
+                                 2, options, VLC_INPUT_OPTION_TRUSTED, -1 );
+    free( psz_uri );
     if( p_input == NULL )
-        goto error;
+        return VLC_EGENERIC;
 
     PL_LOCK;
     if( p_playlist->p_ml_onelevel->p_input )
@@ -189,13 +194,7 @@ int playlist_MLLoad( playlist_t *p_playlist )
                         input_item_subitem_added, p_playlist );
 
     vlc_gc_decref( p_input );
-    free( psz_uri );
     return VLC_SUCCESS;
-
-error:
-    free( psz_uri );
-    free( psz_datadir );
-    return VLC_ENOMEM;
 }
 
 int playlist_MLDump( playlist_t *p_playlist )