From 90cac394f9e49fb2ccc5e588dd78e093e0510c4e Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 2 Jan 2016 14:34:22 +0000 Subject: MirLua: added setting c libs path via folders plugin git-svn-id: http://svn.miranda-ng.org/main/trunk@15992 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua_script_loader.cpp | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) (limited to 'plugins/MirLua/src/mlua_script_loader.cpp') diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp index b95b907c8a..b374007dce 100644 --- a/plugins/MirLua/src/mlua_script_loader.cpp +++ b/plugins/MirLua/src/mlua_script_loader.cpp @@ -4,20 +4,6 @@ CLuaScriptLoader::CLuaScriptLoader(lua_State *L) : L(L) { } -void CLuaScriptLoader::RegisterScriptsFolder(const char *path) -{ - lua_getglobal(L, "package"); - lua_getfield(L, -1, "path"); - const char *oldPath = luaL_checkstring(L, -1); - lua_pop(L, 1); - if (!mir_strlen(oldPath)) - lua_pushfstring(L, "%s\\?.lua", path); - else - lua_pushfstring(L, "%s;%s\\?.lua", oldPath, path); - lua_setfield(L, -2, "path"); - lua_pop(L, 1); -} - void CLuaScriptLoader::LoadScript(const TCHAR *scriptDir, const TCHAR *file) { TCHAR fullPath[MAX_PATH], path[MAX_PATH]; @@ -43,14 +29,15 @@ void CLuaScriptLoader::LoadScript(const TCHAR *scriptDir, const TCHAR *file) } } -void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir) +void CLuaScriptLoader::LoadScripts() { + TCHAR scriptDir[MAX_PATH]; + FoldersGetCustomPathT(g_hScriptsFolder, scriptDir, _countof(scriptDir), VARST(MIRLUA_PATHT)); + TCHAR buf[4096]; mir_sntprintf(buf, _T("Loading scripts from %s"), scriptDir); CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf); - RegisterScriptsFolder(ptrA(mir_utf8encodeT(scriptDir))); - TCHAR searchMask[MAX_PATH]; mir_sntprintf(searchMask, _T("%s\\%s"), scriptDir, _T("*.lua")); @@ -70,9 +57,5 @@ void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir) void CLuaScriptLoader::Load(lua_State *L) { - TCHAR scriptDir[MAX_PATH]; - CLuaScriptLoader loader(L); - - FoldersGetCustomPathT(g_hCommonScriptFolder, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT)); - loader.LoadScripts(scriptDir); + CLuaScriptLoader(L).LoadScripts(); } \ No newline at end of file -- cgit v1.2.3