client: buildat.extension_path(name)
This commit is contained in:
parent
61d541b8b3
commit
6e8a85e51d
@ -3,8 +3,7 @@
|
|||||||
-- Copyright 2014 Perttu Ahola <celeron55@gmail.com>
|
-- Copyright 2014 Perttu Ahola <celeron55@gmail.com>
|
||||||
local log = buildat.Logger("__client/api")
|
local log = buildat.Logger("__client/api")
|
||||||
|
|
||||||
function buildat.connect_server(address)
|
buildat.connect_server = __buildat_connect_server
|
||||||
return __buildat_connect_server(address)
|
buildat.extension_path = __buildat_extension_path
|
||||||
end
|
|
||||||
|
|
||||||
-- vim: set noet ts=4 sw=4:
|
-- vim: set noet ts=4 sw=4:
|
||||||
|
@ -5,7 +5,7 @@ local log = buildat.Logger("__client/extensions")
|
|||||||
|
|
||||||
function __buildat_load_extension(name)
|
function __buildat_load_extension(name)
|
||||||
log:info("__buildat_load_extension(\""..name.."\")")
|
log:info("__buildat_load_extension(\""..name.."\")")
|
||||||
local path = __buildat_get_path("share").."/extensions/"..name.."/init.lua"
|
local path = __buildat_extension_path(name).."/init.lua"
|
||||||
local script, err = loadfile(path)
|
local script, err = loadfile(path)
|
||||||
if script == nil then
|
if script == nil then
|
||||||
log:error("Extension could not be opened: "..name.." at "..path..": "..err)
|
log:error("Extension could not be opened: "..name.." at "..path..": "..err)
|
||||||
|
@ -48,6 +48,8 @@ Extensions and modules use require("buildat/extension/<name>") to use extensions
|
|||||||
buildat.connect_server(address)
|
buildat.connect_server(address)
|
||||||
- Address may include port in format "host:port" or "[host]:port"
|
- Address may include port in format "host:port" or "[host]:port"
|
||||||
|
|
||||||
|
buildat.extension_path(name)
|
||||||
|
|
||||||
The sandbox environment
|
The sandbox environment
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
|
@ -188,6 +188,7 @@ struct CApp: public App, public magic::Application
|
|||||||
DEF_BUILDAT_FUNC(get_file_content)
|
DEF_BUILDAT_FUNC(get_file_content)
|
||||||
DEF_BUILDAT_FUNC(get_file_path)
|
DEF_BUILDAT_FUNC(get_file_path)
|
||||||
DEF_BUILDAT_FUNC(get_path)
|
DEF_BUILDAT_FUNC(get_path)
|
||||||
|
DEF_BUILDAT_FUNC(extension_path)
|
||||||
DEF_BUILDAT_FUNC(mkdir)
|
DEF_BUILDAT_FUNC(mkdir)
|
||||||
DEF_BUILDAT_FUNC(pcall)
|
DEF_BUILDAT_FUNC(pcall)
|
||||||
DEF_BUILDAT_FUNC(cereal_binary_input)
|
DEF_BUILDAT_FUNC(cereal_binary_input)
|
||||||
@ -350,6 +351,17 @@ struct CApp: public App, public magic::Application
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// extension_path(name: string)
|
||||||
|
static int l_extension_path(lua_State *L)
|
||||||
|
{
|
||||||
|
ss_ name = lua_tocppstring(L, 1);
|
||||||
|
ss_ path = g_client_config.share_path+"/extensions/"+name;
|
||||||
|
// TODO: Check if extension actually exists and do something suitable if
|
||||||
|
// not
|
||||||
|
lua_pushlstring(L, path.c_str(), path.size());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// mkdir(path: string)
|
// mkdir(path: string)
|
||||||
static int l_mkdir(lua_State *L)
|
static int l_mkdir(lua_State *L)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user