#endif
#include <vlc/vlc.h>
+#include <vlc_plugin.h>
#include <vlc_meta.h>
#include <vlc_charset.h>
#include <vlc_aout.h>
}
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 )
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)
{
int i_ret = VLC_EGENERIC;
- DIR *dir = NULL;
char **ppsz_filelist = NULL;
char **ppsz_fileend = NULL;
char **ppsz_file;
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;
for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
free( *ppsz_dir );
- if( dir ) closedir( dir );
-
return i_ret;
}