From 92ebfe8b665bd5843cc3b91b8dddc07e1497ffef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= <funman@videolan.org>
Date: Thu, 30 Aug 2007 01:10:14 +0000
Subject: [PATCH] Checks if ml.xsp is present before loading it

---
 src/playlist/loadsave.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/playlist/loadsave.c b/src/playlist/loadsave.c
index 23d903fb95e8..8eedaf7751f5 100644
--- a/src/playlist/loadsave.c
+++ b/src/playlist/loadsave.c
@@ -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 )
     {
-- 
GitLab