User-space recursive watcher
@jbowtie requested this feature at https://github.com/howeyc/fsnotify/issues/56.
Windows and FSEvents (OS X) can watch a directory tree, in fact FSEvents is built entirely for this purpose:
if you monitor a directory with FSEvents then the monitor is recursive; there is no non-recursive option - @samjacobson https://github.com/howeyc/fsnotify/issues/54#issuecomment-24040227
Ideally fsnotify would expose a way to use this functionality on Windows and Macs.
Unfortunately inotify (Linux, Android), kqueue (BSD, iOS), and FEN (Solaris) don't have this capability.
There is some debate as to whether or not fsnotify should include a user-space recursive watcher to make up the difference. If not, perhaps it can be implemented a separate wrapper or utility library. In any case, it's something often requested, so we should definitely be thinking about it.
Implementation
In two parts:
- Walk subdirectories to Add (or Remove) watches for each directory:
- To avoid watching too much, it may be important to (optionally?) skip hidden directories (.git, .hg).
- My proposal to configure Ops filtering globally at the Watcher level (https://github.com/fsnotify/fsnotify/issues/7) simplifies recursive watching.
- Listen for incoming Create events to watch additional directories as they are created (again, avoiding hidden directories).
Source: fsnotify/fsnotify