-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build Runner: Initial Implementation for File System Watching on Windows #20667
Conversation
Thoughts on where or how I can reintroduce it? Or if there is an Nt way it can be replicated? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-adding kernel32.ReadDirectoryChangesW
seems fine for now IMO. The Nt implementation can be figured out later (FWIW it looks like the relevant ntdll function is NtNotifyChangeDirectoryFileEx
)
I added an error return to readChanges and some accountability for resources. I still need to deal with this point though:
|
Instead of keying on the file handle itself, which is determined to be different each NtCreateFile call, would it be best to key on a FILE_ID_INFORMATION structure returned by NtQueryInformationFile? I believe that it is unique per file and volume. If it already exists, I would just close that handle and keep the existing one open. edit: Further reading I found that |
I think the way to go might be:
Then hash the combination of those. Some examples of calling
(I'd recommend using that |
Forgot that I had to add |
8effc49
to
4329052
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good IMO, nice work!
Seems to be working as expected from my testing. Tested on NTFS, FAT32, and a networked Samba share and they all worked fine.
- additionally, the parameter must be nonzero: https://learn.microsoft.com/en-us/windows/win32/api/synchapi/nf-synchapi-waitformultipleobjects
- additionally, introduces FileNotifyChangeFilter to improve use/readability
Nice work! |
Closes #20598.
This initial implementation has the limit of 64 directories due to the usage of WaitForMultipleObjects. If merged, a follow up issue should be created to track overcoming that limitation.Using IO completion ports instead of WaitForMultipleObjects, I am able to observe more than 64 directories at once.
BTW First time contributing, not very experienced with contributing on GitHub in general, but I love Zig. And I saw this issue and thought it would be a good learning opportunity for me.