Skip to content

Commit 2b8f444

Browse files
committed
windows: reintroduce ReadDirectoryChangesW
- additionally, introduces FileNotifyChangeFilter to improve use/readability
1 parent 9323a00 commit 2b8f444

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

lib/std/os/windows.zig

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3929,14 +3929,21 @@ pub const FILE_ACTION_RENAMED_NEW_NAME = 0x00000005;
39293929

39303930
pub const LPOVERLAPPED_COMPLETION_ROUTINE = ?*const fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void;
39313931

3932-
pub const FILE_NOTIFY_CHANGE_CREATION = 64;
3933-
pub const FILE_NOTIFY_CHANGE_SIZE = 8;
3934-
pub const FILE_NOTIFY_CHANGE_SECURITY = 256;
3935-
pub const FILE_NOTIFY_CHANGE_LAST_ACCESS = 32;
3936-
pub const FILE_NOTIFY_CHANGE_LAST_WRITE = 16;
3937-
pub const FILE_NOTIFY_CHANGE_DIR_NAME = 2;
3938-
pub const FILE_NOTIFY_CHANGE_FILE_NAME = 1;
3939-
pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = 4;
3932+
pub 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

39413948
pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct {
39423949
dwSize: COORD,

lib/std/os/windows/kernel32.zig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ const WINAPI = windows.WINAPI;
4545
const WORD = windows.WORD;
4646

4747
// I/O - Filesystem
48+
49+
pub 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.
4961
pub extern "kernel32" fn CancelIo(
5062
hFile: HANDLE,

0 commit comments

Comments
 (0)