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 LPOVERLAPPED_COMPLETION_ROUTINE = ?*const fn (DWORD, DWORD, *OVERLAPPED) callconv(.C) void;
pub const FILE_NOTIFY_CHANGE_CREATION = 64; pub const FileNotifyChangeFilter = packed struct(DWORD) {
pub const FILE_NOTIFY_CHANGE_SIZE = 8; file_name: bool = false,
pub const FILE_NOTIFY_CHANGE_SECURITY = 256; dir_name: bool = false,
pub const FILE_NOTIFY_CHANGE_LAST_ACCESS = 32; attributes: bool = false,
pub const FILE_NOTIFY_CHANGE_LAST_WRITE = 16; size: bool = false,
pub const FILE_NOTIFY_CHANGE_DIR_NAME = 2; last_write: bool = false,
pub const FILE_NOTIFY_CHANGE_FILE_NAME = 1; last_access: bool = false,
pub const FILE_NOTIFY_CHANGE_ATTRIBUTES = 4; 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 { pub const CONSOLE_SCREEN_BUFFER_INFO = extern struct {
dwSize: COORD, dwSize: COORD,

View File

@ -45,6 +45,18 @@ const WINAPI = windows.WINAPI;
const WORD = windows.WORD; const WORD = windows.WORD;
// I/O - Filesystem // 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. // TODO: Wrapper around NtCancelIoFile.
pub extern "kernel32" fn CancelIo( pub extern "kernel32" fn CancelIo(
hFile: HANDLE, hFile: HANDLE,