-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Summary
I'd like to propose adding Windows support to FileMonitor using the ReadDirectoryChangesW Win32 API.
Motivation
FileMonitor currently supports macOS (via FSEventStream) and Linux (via inotify), but Windows is not supported. Adding Windows support would make FileMonitor a truly cross-platform file monitoring solution.
Proposed Implementation
I'm willing to contribute this feature. The implementation would follow the existing architecture:
-
New target:
FileMonitorWindowscontainingWindowsWatcher.swift -
Windows API: Use
ReadDirectoryChangesWto monitor directory changes -
Event mapping:
FILE_ACTION_ADDED→.addedFILE_ACTION_REMOVED→.deletedFILE_ACTION_MODIFIED→.changedFILE_ACTION_RENAMED_*→.deleted+.added
-
Package.swift update: Add conditional dependency for Windows
-
CI: Add Windows workflow using GitHub Actions
Technical Approach
#if os(Windows)
import WinSDK
import FileMonitorShared
public final class WindowsWatcher: WatcherProtocol {
// Use ReadDirectoryChangesW with synchronous I/O
// Parse FILE_NOTIFY_INFORMATION structures
// Map to FileChangeEvent enum
}
#endifThe Windows API provides native file system change notifications similar to inotify on Linux, making it a good fit for the existing architecture.
Questions
- Would you be open to accepting a PR for this feature?
- Any specific requirements or patterns you'd like me to follow?
Thank you for maintaining this useful library!