Commit c272f614 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Lua: look for scripts in $(pkglibdir) (refs #19324)

Add $(pkglibdir)/lua/TYPE as alternative to $(pkgdatadir)/lua/TYPE.
parent 2c8baef4
......@@ -197,36 +197,39 @@ static int file_compare( const char **a, const char **b )
return strcmp( *a, *b );
}
int vlclua_dir_list( const char *luadirname, char ***pppsz_dir_list )
static char **vlclua_dir_list_append( char **restrict list, char *basedir,
const char *luadirname )
{
#define MAX_DIR_LIST_SIZE 5
*pppsz_dir_list = malloc(MAX_DIR_LIST_SIZE*sizeof(char *));
if (!*pppsz_dir_list)
return VLC_EGENERIC;
char **ppsz_dir_list = *pppsz_dir_list;
if (unlikely(basedir == NULL))
return list;
int i = 0;
char *datadir = config_GetUserDir( VLC_DATA_DIR );
if (likely(asprintf(list, "%s"DIR_SEP"lua"DIR_SEP"%s",
basedir, luadirname) != -1))
list++;
if( likely(datadir != NULL)
&& likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",
datadir, luadirname ) != -1) )
i++;
free( datadir );
free(basedir);
return list;
}
char *psz_datapath = config_GetDataDir();
if( likely(psz_datapath != NULL) )
{
if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",
psz_datapath, luadirname ) != -1) )
i++;
free( psz_datapath );
}
int vlclua_dir_list(const char *luadirname, char ***restrict listp)
{
char **list = malloc(4 * sizeof(char *));
if (unlikely(list == NULL))
return VLC_EGENERIC;
*listp = list;
/* Lua scripts in user-specific data directory */
list = vlclua_dir_list_append(list, config_GetUserDir(VLC_DATA_DIR),
luadirname);
ppsz_dir_list[i] = NULL;
/* Tokenized Lua scripts in architecture-specific data directory */
list = vlclua_dir_list_append(list, config_GetLibDir(), luadirname);
assert( i < MAX_DIR_LIST_SIZE);
/* Source Lua Scripts in architecture-independent data directory */
list = vlclua_dir_list_append(list, config_GetDataDir(), luadirname);
*list = NULL;
return VLC_SUCCESS;
}
......
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