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 23d903f..8eedaf7 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 )
     {