diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-06-24 13:08:55 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-06-24 13:08:55 +0000 |
commit | 0ccdb951979ead80e9264233776b9147ff701fc7 (patch) | |
tree | 904e408efb04c346e1694089cd863e6a56986563 /plugins/MirLua/src/mlua_script_loader.cpp | |
parent | 2104de821739508078c23dcc046a5640bf300ea1 (diff) |
MirLua: options and log cosmetics
git-svn-id: http://svn.miranda-ng.org/main/trunk@14362 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua_script_loader.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua_script_loader.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp index abeb18d8d4..663ad4cd59 100644 --- a/plugins/MirLua/src/mlua_script_loader.cpp +++ b/plugins/MirLua/src/mlua_script_loader.cpp @@ -10,23 +10,28 @@ void CLuaScriptLoader::RegisterScriptsFolder(const char *path) lua_getfield(L, -1, "path");
const char *oldPath = luaL_checkstring(L, -1);
lua_pop(L, 1);
- lua_pushfstring(L, "%s;%s\\?.lua", oldPath, path);
+ 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 char *path)
+void CLuaScriptLoader::LoadScript(const TCHAR *path, const TCHAR *name)
{
- if (luaL_dofile(L, path))
+ if (luaL_dofile(L, T2Utf(path)))
{
- const char *error = lua_tostring(L, -1);
- mir_writeLogT(hLogger, _T("%s"), ptrT(mir_utf8decodeT(error)));
+ ptrT error(mir_utf8decodeT(lua_tostring(L, -1)));
+ mir_writeLogT(hLogger, _T(" %s:FAIL\n %s\n"), name, error);
printf("%s\n", lua_tostring(L, -1));
}
+ else mir_writeLogT(hLogger, _T(" %s:OK\n"), name);
}
void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir)
{
+ mir_writeLogT(hLogger, _T("Loading scripts from path %s\n"), scriptDir);
RegisterScriptsFolder(ptrA(mir_utf8encodeT(scriptDir)));
TCHAR searchMask[MAX_PATH];
@@ -45,11 +50,12 @@ void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir) mir_sntprintf(fullPath, _T("%s\\%s"), scriptDir, fd.cFileName);
PathToRelativeT(fullPath, path);
if (db_get_b(NULL, MODULE, _T2A(fd.cFileName), 1))
- LoadScript(T2Utf(path));
+ LoadScript(fullPath, fd.cFileName);
}
} while (FindNextFile(hFind, &fd));
FindClose(hFind);
}
+ mir_writeLogT(hLogger, _T("\n"), scriptDir);
}
void CLuaScriptLoader::Load(lua_State *L, HANDLE hLogger)
@@ -62,4 +68,6 @@ void CLuaScriptLoader::Load(lua_State *L, HANDLE hLogger) FoldersGetCustomPathT(g_hCustomFolderPath, scriptDir, _countof(scriptDir), VARST(CUSTOM_SCRIPTS_PATHT));
loader.LoadScripts(scriptDir);
+
+ mir_writeLogT(hLogger, _T("\n"), scriptDir);
}
\ No newline at end of file |