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

Move vlc.misc.*dir to vlc.config.*dir

parent 8d37aa9a
......@@ -102,12 +102,81 @@ static int vlclua_config_set( lua_State *L )
return 0;
}
/*****************************************************************************
* Directories configuration
*****************************************************************************/
static int vlclua_datadir( lua_State *L )
{
char *psz_data = config_GetDataDir( vlclua_get_this( L ) );
lua_pushstring( L, psz_data );
free( psz_data );
return 1;
}
static int vlclua_userdatadir( lua_State *L )
{
char *dir = config_GetUserDir( VLC_DATA_DIR );
lua_pushstring( L, dir );
free( dir );
return 1;
}
static int vlclua_homedir( lua_State *L )
{
char *home = config_GetUserDir( VLC_HOME_DIR );
lua_pushstring( L, home );
free( home );
return 1;
}
static int vlclua_configdir( lua_State *L )
{
char *dir = config_GetUserDir( VLC_CONFIG_DIR );
lua_pushstring( L, dir );
free( dir );
return 1;
}
static int vlclua_cachedir( lua_State *L )
{
char *dir = config_GetUserDir( VLC_CACHE_DIR );
lua_pushstring( L, dir );
free( dir );
return 1;
}
static int vlclua_datadir_list( lua_State *L )
{
const char *psz_dirname = luaL_checkstring( L, 1 );
char **ppsz_dir_list = NULL;
int i = 1;
if( vlclua_dir_list( vlclua_get_this( L ), psz_dirname, &ppsz_dir_list )
!= VLC_SUCCESS )
return 0;
lua_newtable( L );
for( char **ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
{
lua_pushstring( L, *ppsz_dir );
lua_rawseti( L, -2, i );
i ++;
}
vlclua_dir_list_free( ppsz_dir_list );
return 1;
}
/*****************************************************************************
*
*****************************************************************************/
static const luaL_Reg vlclua_config_reg[] = {
{ "get", vlclua_config_get },
{ "set", vlclua_config_set },
{ "datadir", vlclua_datadir },
{ "userdatadir", vlclua_userdatadir },
{ "homedir", vlclua_homedir },
{ "configdir", vlclua_configdir },
{ "cachedir", vlclua_cachedir },
{ "datadir_list", vlclua_datadir_list },
{ NULL, NULL }
};
......
......@@ -132,68 +132,6 @@ static int vlclua_quit( lua_State *L )
return 0;
}
/*****************************************************************************
* Global properties getters
*****************************************************************************/
static int vlclua_datadir( lua_State *L )
{
char *psz_data = config_GetDataDir( vlclua_get_this( L ) );
lua_pushstring( L, psz_data );
free( psz_data );
return 1;
}
static int vlclua_userdatadir( lua_State *L )
{
char *dir = config_GetUserDir( VLC_DATA_DIR );
lua_pushstring( L, dir );
free( dir );
return 1;
}
static int vlclua_homedir( lua_State *L )
{
char *home = config_GetUserDir( VLC_HOME_DIR );
lua_pushstring( L, home );
free( home );
return 1;
}
static int vlclua_configdir( lua_State *L )
{
char *dir = config_GetUserDir( VLC_CONFIG_DIR );
lua_pushstring( L, dir );
free( dir );
return 1;
}
static int vlclua_cachedir( lua_State *L )
{
char *dir = config_GetUserDir( VLC_CACHE_DIR );
lua_pushstring( L, dir );
free( dir );
return 1;
}
static int vlclua_datadir_list( lua_State *L )
{
const char *psz_dirname = luaL_checkstring( L, 1 );
char **ppsz_dir_list = NULL;
int i = 1;
if( vlclua_dir_list( vlclua_get_this( L ), psz_dirname, &ppsz_dir_list )
!= VLC_SUCCESS )
return 0;
lua_newtable( L );
for( char **ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
{
lua_pushstring( L, *ppsz_dir );
lua_rawseti( L, -2, i );
i ++;
}
vlclua_dir_list_free( ppsz_dir_list );
return 1;
}
/*****************************************************************************
*
*****************************************************************************/
......@@ -348,13 +286,6 @@ static const luaL_Reg vlclua_misc_reg[] = {
{ "copyright", vlclua_copyright },
{ "license", vlclua_license },
{ "datadir", vlclua_datadir },
{ "userdatadir", vlclua_userdatadir },
{ "homedir", vlclua_homedir },
{ "configdir", vlclua_configdir },
{ "cachedir", vlclua_cachedir },
{ "datadir_list", vlclua_datadir_list },
{ "action_id", vlclua_action_id },
{ "mdate", vlclua_mdate },
......
......@@ -48,6 +48,14 @@ Configuration
-------------
config.get( name ): Get the VLC configuration option "name"'s value.
config.set( name, value ): Set the VLC configuration option "name"'s value.
config.datadir(): Get the VLC data directory.
config.userdatadir(): Get the user's VLC data directory.
config.homedir(): Get the user's home directory.
config.configdir(): Get the user's VLC config directory.
config.cachedir(): Get the user's VLC cache directory.
config.datadir_list( name ): FIXME: write description ... or ditch function
if it isn't useful anymore, we have datadir and userdatadir :)
Dialog
------
......@@ -146,15 +154,6 @@ misc.version(): Get the VLC version string.
misc.copyright(): Get the VLC copyright statement.
misc.license(): Get the VLC license.
misc.datadir(): Get the VLC data directory.
misc.userdatadir(): Get the user's VLC data directory.
misc.homedir(): Get the user's home directory.
misc.configdir(): Get the user's VLC config directory.
misc.cachedir(): Get the user's VLC cache directory.
misc.datadir_list( name ): FIXME: write description ... or ditch function
if it isn't useful anymore, we have datadir and userdatadir :)
misc.action_id( name ): get the id of the given action.
misc.mdate(): Get the current date (in microseconds).
......
......@@ -243,7 +243,7 @@ function parse_url_request(request)
end
local function find_datadir(name)
local list = vlc.misc.datadir_list(name)
local list = vlc.config.datadir_list(name)
for _, l in ipairs(list) do
local s = vlc.net.stat(l)
if s then
......
......@@ -380,7 +380,7 @@ getbrowsetable = function ()
result.element._array={}
if dir then
if dir == "~" or dir == "file://~" then dir = vlc.misc.homedir() end
if dir == "~" or dir == "file://~" then dir = vlc.config.homedir() end
-- FIXME: hack for Win32 drive list
if dir~="" then
dir = common.realpath(dir.."/")
......
......@@ -16,11 +16,6 @@ vlc.msg.info('---- Testing misc functions ----')
vlc.msg.info('version: ' .. vlc.misc.version())
vlc.msg.info('copyright: ' .. vlc.misc.copyright())
vlc.msg.info('license: ' .. vlc.misc.license())
vlc.msg.info('datadir: ' .. vlc.misc.datadir())
vlc.msg.info('userdatadir: ' .. vlc.misc.userdatadir())
vlc.msg.info('homedir: ' .. vlc.misc.homedir())
vlc.msg.info('configdir: ' .. vlc.misc.configdir())
vlc.msg.info('cachedir: ' .. vlc.misc.cachedir())
vlc.msg.info('mdate: ' .. vlc.misc.mdate())
vlc.msg.info(' * Testing the timer')
......@@ -30,6 +25,13 @@ vlc.misc.mwait(vlc.misc.mdate()+1000000)
assert(timer_count == 1)
vlc.msg.info(' [done]')
vlc.msg.info('---- Testing config functions ----')
vlc.msg.info('datadir: ' .. vlc.config.datadir())
vlc.msg.info('userdatadir: ' .. vlc.config.userdatadir())
vlc.msg.info('homedir: ' .. vlc.config.homedir())
vlc.msg.info('configdir: ' .. vlc.config.configdir())
vlc.msg.info('cachedir: ' .. vlc.config.cachedir())
vlc.msg.info('---- Testing net functions ----')
vlc.msg.info(' * testing vlc.net.url_parse')
vlc.msg.info(' "filename.ext"')
......
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