zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 2b8f444dde1b7854b18dc553cb6eeb6caca42a8d (tree)
parent 9323a00067b0999b224896573274002d91fd328a
Author: Jarrod Meyer <meyerja.2013@gmail.com>
Date:   Fri, 26 Jul 2024 20:31:20 -0400

windows: reintroduce ReadDirectoryChangesW
- additionally, introduces FileNotifyChangeFilter to improve use/readability

Diffstat:
Mlib/std/os/windows.zig | 23+++++++++++++++--------
Mlib/std/os/windows/kernel32.zig | 12++++++++++++
2 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/lib/std/os/windows.zig b/lib/std/os/windows.zig @@ -3929,14 +3929,21 @@ pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005; pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?*const fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void; -pub const FILE_NOTIFY_CHANGE_CREATION = 64; -pub const FILE_NOTIFY_CHANGE_SIZE = 8; -pub const FILE_NOTIFY_CHANGE_SECURITY = 256; -pub const FILE_NOTIFY_CHANGE_LAST_ACCESS = 32; -pub const FILE_NOTIFY_CHANGE_LAST_WRITE = 16; -pub const FILE_NOTIFY_CHANGE_DIR_NAME = 2; -pub const FILE_NOTIFY_CHANGE_FILE_NAME = 1; -pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = 4; +pub const FileNotifyChangeFilter = packed struct(DWORD) { + file_name: bool = false, + dir_name: bool = false, + attributes: bool = false, + size: bool = false, + last_write: bool = false, + last_access: bool = false, + creation: bool = false, + ea: bool = false, + security: bool = false, + stream_name: bool = false, + stream_size: bool = false, + stream_write: bool = false, + _pad: u20 = 0, +}; pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct { dwSize: COORD, diff --git a/lib/std/os/windows/kernel32.zig b/lib/std/os/windows/kernel32.zig @@ -45,6 +45,18 @@ const WINAPI = windows.WINAPI; const WORD = windows.WORD; // I/O - Filesystem + +pub extern "kernel32" fn ReadDirectoryChangesW( + hDirectory: windows.HANDLE, + lpBuffer: [*]align(@alignOf(windows.FILE_NOTIFY_INFORMATION)) u8, + nBufferLength: windows.DWORD, + bWatchSubtree: windows.BOOL, + dwNotifyFilter: windows.FileNotifyChangeFilter, + lpBytesReturned: ?*windows.DWORD, + lpOverlapped: ?*windows.OVERLAPPED, + lpCompletionRoutine: windows.LPOVERLAPPED_COMPLETION_ROUTINE, +) callconv(windows.WINAPI) windows.BOOL; + // TODO: Wrapper around NtCancelIoFile. pub extern "kernel32" fn CancelIo( hFile: HANDLE,