Skip to content

Feature Request: Windows Support #10

Description

@KrisSimon

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:

  1. New target: FileMonitorWindows containing WindowsWatcher.swift

  2. Windows API: Use ReadDirectoryChangesW to monitor directory changes

  3. Event mapping:

    • FILE_ACTION_ADDED.added
    • FILE_ACTION_REMOVED.deleted
    • FILE_ACTION_MODIFIED.changed
    • FILE_ACTION_RENAMED_*.deleted + .added
  4. Package.swift update: Add conditional dependency for Windows

  5. 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

  1. Would you be open to accepting a PR for this feature?
  2. Any specific requirements or patterns you'd like me to follow?

Thank you for maintaining this useful library!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions