[vlc-commits] Move vlc.misc.*dir to vlc.config.*dir
Rémi Denis-Courmont
git at videolan.org
Sun Mar 11 14:04:15 CET 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar 11 14:29:54 2012 +0200| [f7ee3edcc510959cb85ffde3c350df8c36123c4e] | committer: Rémi Denis-Courmont
Move vlc.misc.*dir to vlc.config.*dir
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f7ee3edcc510959cb85ffde3c350df8c36123c4e
---
modules/lua/libs/configuration.c | 69 +++++++++++++++++++++++++++++++
modules/lua/libs/misc.c | 69 -------------------------------
share/lua/README.txt | 17 ++++----
share/lua/intf/http.lua | 2 +-
share/lua/intf/modules/httprequests.lua | 2 +-
share/lua/intf/test.lua | 12 +++--
6 files changed, 86 insertions(+), 85 deletions(-)
diff --git a/modules/lua/libs/configuration.c b/modules/lua/libs/configuration.c
index 7b5f732..b0c76ce 100644
--- a/modules/lua/libs/configuration.c
+++ b/modules/lua/libs/configuration.c
@@ -103,11 +103,80 @@ static int vlclua_config_set( lua_State *L )
}
/*****************************************************************************
+ * 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 }
};
diff --git a/modules/lua/libs/misc.c b/modules/lua/libs/misc.c
index 40f11bd..a64e227 100644
--- a/modules/lua/libs/misc.c
+++ b/modules/lua/libs/misc.c
@@ -133,68 +133,6 @@ static int vlclua_quit( lua_State *L )
}
/*****************************************************************************
- * 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;
-}
-/*****************************************************************************
*
*****************************************************************************/
static int vlclua_lock_and_wait( lua_State *L )
@@ -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 },
diff --git a/share/lua/README.txt b/share/lua/README.txt
index eeac084..b41fb21 100644
--- a/share/lua/README.txt
+++ b/share/lua/README.txt
@@ -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).
diff --git a/share/lua/intf/http.lua b/share/lua/intf/http.lua
index 8814c56..de37820 100644
--- a/share/lua/intf/http.lua
+++ b/share/lua/intf/http.lua
@@ -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
diff --git a/share/lua/intf/modules/httprequests.lua b/share/lua/intf/modules/httprequests.lua
index 52f3531..95996cc 100644
--- a/share/lua/intf/modules/httprequests.lua
+++ b/share/lua/intf/modules/httprequests.lua
@@ -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.."/")
diff --git a/share/lua/intf/test.lua b/share/lua/intf/test.lua
index 20259e0..54dbf9a 100644
--- a/share/lua/intf/test.lua
+++ b/share/lua/intf/test.lua
@@ -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"')
More information about the vlc-commits
mailing list