]> git.sesse.net Git - vlc/commitdiff
Checks if ml.xsp is present before loading it
authorRafaël Carré <funman@videolan.org>
Thu, 30 Aug 2007 01:10:14 +0000 (01:10 +0000)
committerRafaël Carré <funman@videolan.org>
Thu, 30 Aug 2007 01:10:14 +0000 (01:10 +0000)
src/playlist/loadsave.c

index 23d903fb95e86891ecc9f94aadd3cb9260c5da47..8eedaf7751f57e1c11b9dd38b4f56ebd743ed12f 100644 (file)
@@ -26,6 +26,9 @@
 #include "modules/configuration.h"
 #include <vlc_charset.h>
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
 #include <errno.h>
 
 int playlist_Export( playlist_t * p_playlist, const char *psz_filename ,
@@ -97,6 +100,21 @@ int playlist_MLLoad( playlist_t *p_playlist )
         return VLC_EGENERIC;
     }
 
+    if( asprintf( &psz_uri, "%s" DIR_SEP CONFIG_DIR DIR_SEP
+                        "ml.xsp", psz_homedir ) == -1 )
+    {
+        psz_uri = NULL;
+        goto error;
+    }
+    struct stat p_stat;
+    /* checks if media library file is present */
+    if( utf8_stat( psz_uri , &p_stat ) )
+    {
+        free( psz_uri );
+        return VLC_EGENERIC;
+    }
+    free( psz_uri );
+
     if( asprintf( &psz_uri, "file/xspf-open://%s" DIR_SEP CONFIG_DIR DIR_SEP
                         "ml.xsp", psz_homedir ) == -1 )
     {