Fixed windows dirmonitor issues.

This commit is contained in:
Adam Harrison 2022-04-02 17:03:29 -04:00
parent 562e284d04
commit 974fd9c8d5
3 changed files with 17 additions and 17 deletions

View File

@ -47,9 +47,9 @@ function dirwatch:watch(directory, bool)
return self:scan(directory)
end
self.windows_watch_top = target
end
end
self.windows_watch_count = self.windows_watch_count + 1
end
end
self.watched[directory] = true
else
local value = self.monitor:watch(directory)

View File

@ -70,7 +70,7 @@ static int f_dirmonitor_watch(lua_State *L) {
}
static int f_dirmonitor_unwatch(lua_State *L) {
remove_dirmonitor(*(struct dirmonitor**)luaL_checkudata(L, 1, API_TYPE_DIRMONITOR), luaL_checknumber(L, 2));
remove_dirmonitor(*(struct dirmonitor**)luaL_checkudata(L, 1, API_TYPE_DIRMONITOR), lua_tonumber(L, 2));
return 0;
}

View File

@ -3,7 +3,7 @@
struct dirmonitor {
HANDLE handle;
char buffer[8192];
char buffer[64512];
OVERLAPPED overlapped;
bool running;
};
@ -52,8 +52,8 @@ int check_dirmonitor_win32(struct dirmonitor* monitor, int (*change_callback)(in
monitor->running = false;
for (FILE_NOTIFY_INFORMATION* info = (FILE_NOTIFY_INFORMATION*)monitor->buffer; (char*)info < monitor->buffer + sizeof(monitor->buffer); info = (FILE_NOTIFY_INFORMATION*)((char*)info) + info->NextEntryOffset) {
change_callback(info->FileNameLength, (char*)info->FileName, data);
for (FILE_NOTIFY_INFORMATION* info = (FILE_NOTIFY_INFORMATION*)monitor->buffer; (char*)info < monitor->buffer + sizeof(monitor->buffer); info = (FILE_NOTIFY_INFORMATION*)(((char*)info) + info->NextEntryOffset)) {
change_callback(info->FileNameLength / sizeof(WCHAR), (char*)info->FileName, data);
if (!info->NextEntryOffset)
break;
}