authorgravatar for meyerja.2013@gmail.comJarrod Meyer <meyerja.2013@gmail.com> 2024-07-26 20:31:20-04:00
committergravatar for meyerja.2013@gmail.comJarrod Meyer <meyerja.2013@gmail.com> 2024-07-27 11:32:43-04:00
log2b8f444dde1b7854b18dc553cb6eeb6caca42a8d
tree79beaa597bbe5713068e386a790f4592994f1728
parent9323a00067b0999b224896573274002d91fd328a

windows: reintroduce ReadDirectoryChangesW

- additionally, introduces FileNotifyChangeFilter to improve use/readability

2 files changed, 27 insertions(+), 8 deletions(-)

lib/std/os/windows.zig+15-8
......@@ -3929,14 +3929,21 @@ pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;
39293929
39303930pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?*const fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void;
39313931
3932pub const FILE_NOTIFY_CHANGE_CREATION = 64;
3933pub const FILE_NOTIFY_CHANGE_SIZE = 8;
3934pub const FILE_NOTIFY_CHANGE_SECURITY = 256;
3935pub const FILE_NOTIFY_CHANGE_LAST_ACCESS = 32;
3936pub const FILE_NOTIFY_CHANGE_LAST_WRITE = 16;
3937pub const FILE_NOTIFY_CHANGE_DIR_NAME = 2;
3938pub const FILE_NOTIFY_CHANGE_FILE_NAME = 1;
3939pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = 4;
3932pub const FileNotifyChangeFilter = packed struct(DWORD) {
3933 file_name: bool = false,
3934 dir_name: bool = false,
3935 attributes: bool = false,
3936 size: bool = false,
3937 last_write: bool = false,
3938 last_access: bool = false,
3939 creation: bool = false,
3940 ea: bool = false,
3941 security: bool = false,
3942 stream_name: bool = false,
3943 stream_size: bool = false,
3944 stream_write: bool = false,
3945 _pad: u20 = 0,
3946};
39403947
39413948pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct {
39423949 dwSize: COORD,
lib/std/os/windows/kernel32.zig+12
......@@ -45,6 +45,18 @@ const WINAPI = windows.WINAPI;
4545const WORD = windows.WORD;
4646
4747// I/O - Filesystem
48
49pub extern "kernel32" fn ReadDirectoryChangesW(
50 hDirectory: windows.HANDLE,
51 lpBuffer: [*]align(@alignOf(windows.FILE_NOTIFY_INFORMATION)) u8,
52 nBufferLength: windows.DWORD,
53 bWatchSubtree: windows.BOOL,
54 dwNotifyFilter: windows.FileNotifyChangeFilter,
55 lpBytesReturned: ?*windows.DWORD,
56 lpOverlapped: ?*windows.OVERLAPPED,
57 lpCompletionRoutine: windows.LPOVERLAPPED_COMPLETION_ROUTINE,
58) callconv(windows.WINAPI) windows.BOOL;
59
4860// TODO: Wrapper around NtCancelIoFile.
4961pub extern "kernel32" fn CancelIo(
5062 hFile: HANDLE,