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: FileMonitorWindows containing WindowsWatcher.swift
-
Windows API: Use ReadDirectoryChangesW to monitor directory changes
-
Event mapping:
FILE_ACTION_ADDED → .added
FILE_ACTION_REMOVED → .deleted
FILE_ACTION_MODIFIED → .changed
FILE_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
}
#endif
The 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!
Summary
I'd like to propose adding Windows support to FileMonitor using the
ReadDirectoryChangesWWin32 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.swiftWindows API: Use
ReadDirectoryChangesWto monitor directory changesEvent mapping:
FILE_ACTION_ADDED→.addedFILE_ACTION_REMOVED→.deletedFILE_ACTION_MODIFIED→.changedFILE_ACTION_RENAMED_*→.deleted+.addedPackage.swift update: Add conditional dependency for Windows
CI: Add Windows workflow using GitHub Actions
Technical Approach
The Windows API provides native file system change notifications similar to inotify on Linux, making it a good fit for the existing architecture.
Questions
Thank you for maintaining this useful library!