This commit is contained in:
Matthew 2026-06-27 15:51:46 +10:00
parent 253be45581
commit 031f7c74b3

View File

@ -1547,14 +1547,14 @@ struct Watcher
{ {
Arena arena; Arena arena;
u8[] buffer; u8[] buffer;
WatcherH handle; WatcherHandle handle;
WatchH dir_handle; WatchHandle dir_handle;
u8[] watched_dir; u8[] watched_dir;
bool blocking; bool blocking;
} }
alias WatcherH = int; alias WatcherHandle = int;
alias WatchH = int; alias WatchHandle = int;
enum WatchType enum WatchType
{ {
@ -1607,15 +1607,15 @@ ViewChanges(Watcher* watcher)
if(length > 0) if(length > 0)
{ {
i64 count = 0; i64 count = 0;
i64 i = 0; i64 index = 0;
while(i < length) while(index < length)
{ {
inotify_event* event = (cast(inotify_event*)(watcher.buffer.ptr + i)); inotify_event* event = (cast(inotify_event*)(watcher.buffer.ptr + index));
count += 1; count += 1;
assert(event.wd == watcher.dir_handle); assert(event.wd == watcher.dir_handle);
i += inotify_event.sizeof + event.len; index += inotify_event.sizeof + event.len;
} }
if(count > 0) if(count > 0)
@ -1631,15 +1631,15 @@ ViewChanges(Watcher* watcher)
i64 m_count = 0; i64 m_count = 0;
events = Alloc!(WatchEvent)(&watcher.arena, count); events = Alloc!(WatchEvent)(&watcher.arena, count);
count = 0; count = 0;
i = 0; index = 0;
while (i < length) while (index < length)
{ {
inotify_event* event = (cast(inotify_event*)(watcher.buffer.ptr + i)); inotify_event* event = (cast(inotify_event*)(watcher.buffer.ptr + index));
if(event.len > 0) if(event.len > 0)
{ {
u8[] file_name = (cast(u8*)event.name)[0 .. strlen(event.name.ptr)]; u8[] file_name = (cast(u8*)event.name)[0 .. strlen(event.name.ptr)];
if(event.mask & IN_MOVED_FROM || event.mask & IN_MOVED_TO) if(event.mask & (IN_MOVED_FROM | IN_MOVED_TO))
{ {
bool from = (event.mask & IN_MOVED_FROM) > 0; bool from = (event.mask & IN_MOVED_FROM) > 0;
@ -1726,7 +1726,7 @@ ViewChanges(Watcher* watcher)
count += 1; count += 1;
} }
i += inotify_event.sizeof + event.len; index += inotify_event.sizeof + event.len;
} }
} }
} }