aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/core/dirwatch.lua24
-rw-r--r--src/api/dirmonitor.c2
-rw-r--r--src/api/dirmonitor/win32.c8
3 files changed, 17 insertions, 17 deletions
diff --git a/data/core/dirwatch.lua b/data/core/dirwatch.lua
index 2bcf5508..772a7f5f 100644
--- a/data/core/dirwatch.lua
+++ b/data/core/dirwatch.lua
@@ -36,20 +36,20 @@ function dirwatch:watch(directory, bool)
if not self.watched[directory] and not self.scanned[directory] then
if PLATFORM == "Windows" then
if not self.windows_watch_top or directory:find(self.windows_watch_top, 1, true) ~= 1 then
- -- Get the highest level of directory that is common to this directory, and the original.
- local target = directory
- while self.windows_watch_top and self.windows_watch_top:find(target, 1, true) ~= 1 do
- target = common.dirname(target)
- end
- if target ~= self.windows_watch_top then
- local value = self.monitor:watch(target)
- if value and value < 0 then
- return self:scan(directory)
+ -- Get the highest level of directory that is common to this directory, and the original.
+ local target = directory
+ while self.windows_watch_top and self.windows_watch_top:find(target, 1, true) ~= 1 do
+ target = common.dirname(target)
+ end
+ if target ~= self.windows_watch_top then
+ local value = self.monitor:watch(target)
+ if value and value < 0 then
+ return self:scan(directory)
+ end
+ self.windows_watch_top = target
+ end
end
- self.windows_watch_top = target
self.windows_watch_count = self.windows_watch_count + 1
- end
- end
self.watched[directory] = true
else
local value = self.monitor:watch(directory)
diff --git a/src/api/dirmonitor.c b/src/api/dirmonitor.c
index 3c79c0d9..6d14fbe1 100644
--- a/src/api/dirmonitor.c
+++ b/src/api/dirmonitor.c
@@ -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;
}
diff --git a/src/api/dirmonitor/win32.c b/src/api/dirmonitor/win32.c
index 9dd2a254..d5945856 100644
--- a/src/api/dirmonitor/win32.c
+++ b/src/api/dirmonitor/win32.c
@@ -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;
}
@@ -74,4 +74,4 @@ int add_dirmonitor_win32(struct dirmonitor* monitor, const char* path) {
void remove_dirmonitor_win32(struct dirmonitor* monitor, int fd) {
close_monitor_handle(monitor);
-} \ No newline at end of file
+}