]> go.fuhry.dev Git - fsnotify.git/commit
Add recursive watcher for Windows backend (#540)
authorMartin Tournoij <martin@arp242.net>
Tue, 20 Dec 2022 12:50:49 +0000 (13:50 +0100)
committerGitHub <noreply@github.com>
Tue, 20 Dec 2022 12:50:49 +0000 (13:50 +0100)
commit736c884e348205ff9da32fbe6258bdd20a166a1e
treea0af676e0931f4909a1243a345e601dbd1eddc1c
parent1a7658379b30f8c5a38a75d5a5dcc605eca491f4
Add recursive watcher for Windows backend (#540)

Recursive watches can be added by using a "/..." parameter, similar to
the Go command:

w.Add("dir")         // Behaves as before.
w.Add("dir/...")     // Watch dir and all paths underneath it.

w.Remove("dir")      // Remove the watch for dir and, if
                     // recursive, all paths underneath it too

w.Remove("dir/...")  // Behaves like just "dir" if the path was
                     // recursive, error otherwise (probably
                     // want to add recursive remove too at some
                     // point).

The advantage of using "/..." vs. an option is that it can be easily
specified in configuration files and the like; for example from a TOML
file:

[watches]
dirs = ["/tmp/one", "/tmp/two/..."]

Options for this were previously discussed at:
https://github.com/fsnotify/fsnotify/pull/339#discussion_r788246013

This should be expanded to other backends too; I started with Windows
because the implementation is the both the easiest and has the least
amount of control (just setting a boolean parameter), and we can focus
mostly on writing tests and documentation and the for it, and we can
then match the inotify and kqueue behaviour to the Windows one.

Fixes #21

Co-authored-by: Milas Bowman <milasb@gmail.com>
CHANGELOG.md
backend_fen.go
backend_inotify.go
backend_inotify_test.go
backend_kqueue.go
backend_other.go
backend_windows.go
fsnotify.go
fsnotify_test.go
helpers_test.go
mkdoc.zsh