]> git.sesse.net Git - vlc/blobdiff - modules/misc/lua/vlc.c
Include vlc_plugin.h as needed
[vlc] / modules / misc / lua / vlc.c
index d985340b4a4f42118cff57f643d5fc93a0315782..20deb0c39b8f192125c16a6cf44f3fba3c067a15 100644 (file)
@@ -34,6 +34,7 @@
 #endif
 
 #include <vlc/vlc.h>
+#include <vlc_plugin.h>
 #include <vlc_meta.h>
 #include <vlc_charset.h>
 #include <vlc_aout.h>
@@ -164,12 +165,16 @@ int vlclua_homedir( lua_State *L )
 }
 int vlclua_configdir( lua_State *L )
 {
-    lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_configdir );
+    char *dir = config_GetUserConfDir();
+    lua_pushstring( L, dir );
+    free( dir );
     return 1;
 }
 int vlclua_cachedir( lua_State *L )
 {
-    lua_pushstring( L, vlclua_get_this( L )->p_libvlc->psz_cachedir );
+    char *dir = config_GetCacheDir();
+    lua_pushstring( L, dir );
+    free( dir );
     return 1;
 }
 int vlclua_datadir_list( lua_State *L )
@@ -400,9 +405,17 @@ int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
                      char **ppsz_dir_list )
 {
     int i = 0;
+    char *datadir = config_GetUserDataDir();
+    if( datadir == NULL )
+        return VLC_ENOMEM;
+
     if( asprintf( &ppsz_dir_list[i], "%s" DIR_SEP "lua" DIR_SEP "%s",
-                   p_this->p_libvlc->psz_datadir, luadirname ) < 0 )
+                   datadir, luadirname ) < 0 )
+    {
+        free( datadir );
         return VLC_ENOMEM;
+    }
+    free( datadir );
     i++;
 
 #   if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
@@ -460,7 +473,6 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
 {
     int i_ret = VLC_EGENERIC;
 
-    DIR   *dir           = NULL;
     char **ppsz_filelist = NULL;
     char **ppsz_fileend  = NULL;
     char **ppsz_file;
@@ -487,16 +499,8 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
             ppsz_filelist = NULL;
         }
 
-        if( dir )
-        {
-            closedir( dir );
-        }
-
         msg_Dbg( p_this, "Trying Lua scripts in %s", *ppsz_dir );
-        dir = utf8_opendir( *ppsz_dir );
-
-        if( !dir ) continue;
-        i_files = utf8_loaddir( dir, &ppsz_filelist, file_select,
+        i_files = utf8_scandir( *ppsz_dir, &ppsz_filelist, file_select,
                                 file_compare );
         if( i_files < 1 ) continue;
         ppsz_fileend = ppsz_filelist + i_files;
@@ -528,8 +532,6 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
     for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
         free( *ppsz_dir );
 
-    if( dir ) closedir( dir );
-
     return i_ret;
 }