Commit 0df4f0cd authored by Damien Fouilleul's avatar Damien Fouilleul

lua: fixed search paths list for scripts, needs more work for Linux

parent 2dffeb14
...@@ -252,7 +252,7 @@ int E_(Import_LuaPlaylist)( vlc_object_t *p_this ) ...@@ -252,7 +252,7 @@ int E_(Import_LuaPlaylist)( vlc_object_t *p_this )
char **ppsz_fileend = NULL; char **ppsz_fileend = NULL;
char **ppsz_file; char **ppsz_file;
char *ppsz_dir_list[] = { NULL, NULL, NULL }; char *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
char **ppsz_dir; char **ppsz_dir;
p_demux->p_sys = (demux_sys_t*)malloc( sizeof( demux_sys_t ) ); p_demux->p_sys = (demux_sys_t*)malloc( sizeof( demux_sys_t ) );
...@@ -289,17 +289,17 @@ int E_(Import_LuaPlaylist)( vlc_object_t *p_this ) ...@@ -289,17 +289,17 @@ int E_(Import_LuaPlaylist)( vlc_object_t *p_this )
lua_pop( p_state, 1 ); lua_pop( p_state, 1 );
ppsz_dir_list[0] = malloc( strlen( p_demux->p_libvlc->psz_homedir ) if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP CONFIG_DIR DIR_SEP "luaplaylist",
+ strlen( DIR_SEP CONFIG_DIR DIR_SEP "luaplaylist" ) + 1 ); p_demux->p_libvlc->psz_homedir ) < -1 )
sprintf( ppsz_dir_list[0], "%s" DIR_SEP CONFIG_DIR DIR_SEP "luaplaylist", return VLC_ENOMEM;
p_demux->p_libvlc->psz_homedir );
# if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32) # if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
{ {
char *psz_vlcpath = config_GetDataDir( p_demux ); char *psz_vlcpath = config_GetDataDir( p_demux );
ppsz_dir_list[1] = malloc( strlen( psz_vlcpath ) + strlen( "luaplaylist" ) + 1 ); if( asprintf( &ppsz_dir_list[1], "%s" DIR_SEP "luaplaylist", psz_vlcpath ) < 0 )
if( !ppsz_dir_list[1] ) return VLC_ENOMEM; return VLC_ENOMEM;
sprintf( ppsz_dir_list[1], "%s" DIR_SEP "luaplaylist", psz_vlcpath ); if( asprintf( &ppsz_dir_list[2], "%s" DIR_SEP "share" DIR_SEP "luaplaylist", psz_vlcpath ) < 0 )
return VLC_ENOMEM;
} }
# else # else
{ {
...@@ -347,7 +347,7 @@ int E_(Import_LuaPlaylist)( vlc_object_t *p_this ) ...@@ -347,7 +347,7 @@ int E_(Import_LuaPlaylist)( vlc_object_t *p_this )
for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend; ppsz_file++ ) for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend; ppsz_file++ )
{ {
free( psz_filename ); psz_filename = NULL; free( psz_filename ); psz_filename = NULL;
asprintf( &psz_filename, "%s/%s", *ppsz_dir, *ppsz_file ); asprintf( &psz_filename, "%s" DIR_SEP "%s", *ppsz_dir, *ppsz_file );
msg_Dbg( p_demux, "Trying Lua playlist script %s", psz_filename ); msg_Dbg( p_demux, "Trying Lua playlist script %s", psz_filename );
p_demux->p_sys->psz_filename = psz_filename; p_demux->p_sys->psz_filename = psz_filename;
......
...@@ -292,20 +292,21 @@ static int vlclua_scripts_batch_execute( vlc_object_t *p_this, ...@@ -292,20 +292,21 @@ static int vlclua_scripts_batch_execute( vlc_object_t *p_this,
char **ppsz_fileend = NULL; char **ppsz_fileend = NULL;
char **ppsz_file; char **ppsz_file;
char *ppsz_dir_list[] = { NULL, NULL, NULL }; char *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
char **ppsz_dir; char **ppsz_dir;
ppsz_dir_list[0] = malloc( strlen( p_this->p_libvlc->psz_homedir ) if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP CONFIG_DIR DIR_SEP "%s", p_this->p_libvlc->psz_homedir,
+ strlen( DIR_SEP CONFIG_DIR DIR_SEP ) + strlen( luadirname ) + 1 ); luadirname ) < 0 )
sprintf( ppsz_dir_list[0], "%s" DIR_SEP CONFIG_DIR DIR_SEP "%s", return VLC_ENOMEM;
p_this->p_libvlc->psz_homedir, luadirname );
# if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32) # if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
{ {
const char *psz_vlcpath = config_GetDataDir( p_this ); const char *psz_vlcpath = config_GetDataDir( p_this );
ppsz_dir_list[1] = malloc( strlen( psz_vlcpath ) + strlen( luadirname ) + 1 ); if( asprintf( &ppsz_dir_list[1], "%s" DIR_SEP "%s", psz_vlcpath, luadirname ) < 0 )
if( !ppsz_dir_list[1] ) return VLC_ENOMEM; return VLC_ENOMEM;
sprintf( ppsz_dir_list[1], "%s" DIR_SEP "%s", psz_vlcpath, luadirname );
if( asprintf( &ppsz_dir_list[2], "%s" DIR_SEP "share" DIR_SEP "%s", psz_vlcpath, luadirname ) < 0 )
return VLC_ENOMEM;
} }
# endif # endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment