[vlc-devel] commit: playlist_MLLoad: format library URI correctly ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue Jun 23 21:38:24 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Denis-Courmont <remi at remlab.net> | Tue Jun 23 22:13:24 2009 +0300| [f42e19995035ab12cfb4f7faa9ae09e8490e3b6a] | committer: Derk-Jan Hartman 

playlist_MLLoad: format library URI correctly
(cherry picked from commit c4dcc7a5a6763e08f641227270ca040192e44af0)

Signed-off-by: Derk-Jan Hartman <hartman at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f42e19995035ab12cfb4f7faa9ae09e8490e3b6a
---

 src/playlist/loadsave.c |   47 +++++++++++++++++++++++------------------------
 1 files changed, 23 insertions(+), 24 deletions(-)

diff --git a/src/playlist/loadsave.c b/src/playlist/loadsave.c
index 5de646a..80abaad 100644
--- a/src/playlist/loadsave.c
+++ b/src/playlist/loadsave.c
@@ -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 )




More information about the vlc-devel mailing list