gmethvin/directory-watcher

Allow watching directory non-recursively

Opened this issue · 1 comments

I think it would be a nice addition to allow watching a directory non-recursively.

Currently, when registering a Path with the builder, the watcher is either set up with the FILE_TREE modifier or recursively for all descendant directories, depending on system capabilities. I circumvent this by instantiating the watcher with an empty path list, then initializing paths and pathHashes with a single path and hashes for all files, and then calling register(path, false), all using reflection. This does what I want, but needless to say, that's not great practice ;)

Thanks for the great library!

I think it would certainly be possible. The logic would be relatively simple except that I'm not quite sure how to configure non-recursive watching for macOS, so maybe we'll just have to filter events that are in a subdirectory.

I'm definitely open to adding the feature. Are you interested in attempting a fix?