windows: reintroduce ReadDirectoryChangesW

- additionally, introduces FileNotifyChangeFilter to improve use/readability
This commit is contained in:
Jarrod Meyer 2024-07-26 20:31:20 -04:00
parent 9323a00067
commit 2b8f444dde
2 changed files with 27 additions and 8 deletions

View File

@ -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,

View File

@ -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,