fix(windows): ignore events with invalid utf-16 paths instead of reporting them with the wrong path

This commit is contained in:
CJ van den Berg 2026-03-14 18:44:26 +01:00
parent 00140fcfe6
commit 8e307e5863
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -140,7 +140,11 @@ fn thread_fn(
const info: *FILE_NOTIFY_INFORMATION = @ptrCast(@alignCast(w.buf[offset..].ptr));
const name_wchars = (&info.FileName).ptr[0 .. info.FileNameLength / 2];
var name_buf: [std.fs.max_path_bytes]u8 = undefined;
const name_len = std.unicode.utf16LeToUtf8(&name_buf, name_wchars) catch 0;
const name_len = std.unicode.utf16LeToUtf8(&name_buf, name_wchars) catch {
if (info.NextEntryOffset == 0) break;
offset += info.NextEntryOffset;
continue;
};
const event_type: EventType = switch (info.Action) {
FILE_ACTION_ADDED => .created,
FILE_ACTION_REMOVED => .deleted,