From 46bf49a25bd772413576d26e8a80020aaae7c9dd Mon Sep 17 00:00:00 2001 From: Adam Harrison Date: Wed, 11 Jan 2023 21:47:54 -0500 Subject: Fixed error handling, and fixed plugin difference call. --- src/lpm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lpm.c') diff --git a/src/lpm.c b/src/lpm.c index b23d3fe..8ad385d 100644 --- a/src/lpm.c +++ b/src/lpm.c @@ -943,6 +943,7 @@ static int lpm_pwd(lua_State* L) { int lpm_flock(lua_State* L) { const char* path = luaL_checkstring(L, 1); luaL_checktype(L, 2, LUA_TFUNCTION); + int error_handler = lua_type(L, 3) == LUA_TFUNCTION ? 3 : 0; #ifdef _WIN32 HANDLE file = CreateFileW(lua_toutf16(L, path), FILE_SHARE_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); if (!file || file == INVALID_HANDLE_VALUE) @@ -963,7 +964,7 @@ int lpm_flock(lua_State* L) { #endif lua_pushvalue(L, 2); lua_pushvalue(L, 1); - int err = lua_pcall(L, 1, 0, 0); + int err = lua_pcall(L, 1, 0, error_handler); #ifdef _WIN32 UnlockFile(file, 0, 0, 1, 0); CloseHandle(file); -- cgit v1.2.3