public sealed class FileWatcherWatches a directory on disk, reporting changes as virtual paths.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
On not writing three backends. docs/plan/03-core-foundation.md asks for per-platform backends over FSEvents, inotify and ReadDirectoryChangesW. The BCL's FileSystemWatcher is already exactly that — those three APIs behind one type, maintained by people who have to keep it working on OS versions that do not exist yet. Reimplementing it would be three P/Invoke surfaces bought with nothing.
What the BCL does not do is any of the things that make watching usable: it reports the four writes a text editor makes as four events, reports an atomic save as a change to a temporary file plus a rename, and reports the program's own writes back to it. That is FileChangeCoalescer's job, and it is where the behaviour and the tests are.
Changes are pulled, not pushed. Drain is called from wherever the consumer wants the effects to land — a frame boundary, between the simulation and the render — rather than the watcher raising events on a platform thread at a moment nobody chose. This is the same reason MainThreadDispatcher drains at defined points.
Fields and properties (4)
public VirtualPath RootThe virtual path this watcher covers.
public TimeSpan DebounceHow long a path must be quiet before its change is reported.
public bool HasOverflowedWhether events were lost since the last ClearOverflow, meaning the only correct response is to rescan.
public long DroppedCountHow many raw events were dropped because the coalescer's buffer was full.
Methods (5)
public FileWatcher(string rootDirectory, VirtualPath virtualRoot)Watches a directory on disk.
public void Suppress(VirtualPath path)Ignores events for a path that this program is about to write.
public int Drain(ICollection<FileChange> into)Takes every change whose debounce window has closed.
public void ClearOverflow()Acknowledges an overflow after rescanning.
public void Dispose()Stops watching.
Used by (3)
- FileWatcherTestsVixen.Core.IO.Tests
- EditorApplicationVixen.Editor.App
- ScriptsModuleVixen.Editor.Scripts