rplevy / ojo

Simple and extensible framework for watching and handling file system events using the Java 7 Watch Service API.
40 stars 1 forks source link

How to register a directory recursively? #2

Open klauern opened 11 years ago

klauern commented 11 years ago

I know that by default, Java's watch service won't register directories under a path recursively, but how would I go about doing that with this library?

rplevy-draker commented 11 years ago

I think that would be a good feature to add.

rplevy-draker commented 11 years ago

Just to be a little more clear, it's part of a category of useful functionality that I intend to add, namely "multiple watchers". I have not implemented multiple watchers yet because I did not need it for my specific use case. It's trivial except for how it changes the work-queue code, which involves some design decisions I will want to consider in more detail.

I think the recursive case should actually just be an option (like parallel mode), and when it is selected, watchers are defined internally for each subdirectory.

klauern commented 11 years ago

Yeah, I'm with you on that. I was using Java's WatchService to write a similar library and was hoping someone had a clean way to handle it. I was stumbling on whether I wanted to differentiate between setup and runtime directory registration, since I would have to register directories created as they are evented in addition to walking the tree at startup.