From ad351277aae9d4c799894fb3357ba2b98b795089 Mon Sep 17 00:00:00 2001 From: Nathan Youngman Date: Thu, 12 Jun 2014 21:30:02 -0600 Subject: [PATCH] Add/Remove watches --- example_test.go | 2 +- fsnotify.go | 8 ++++---- fsnotify_linux.go | 2 +- fsnotify_test.go | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/example_test.go b/example_test.go index f0b33a0..e8a3b07 100644 --- a/example_test.go +++ b/example_test.go @@ -27,7 +27,7 @@ func ExampleNewWatcher() { } }() - err = watcher.Watch("/tmp/foo") + err = watcher.Add("/tmp/foo") if err != nil { log.Fatal(err) } diff --git a/fsnotify.go b/fsnotify.go index 2622de4..7c27f6a 100644 --- a/fsnotify.go +++ b/fsnotify.go @@ -7,13 +7,13 @@ package fsnotify import "fmt" -// Watch a given file path -func (w *Watcher) Watch(path string) error { +// Add starts watching for operations on the named file. +func (w *Watcher) Add(path string) error { return w.watch(path) } -// Remove a watch on a file -func (w *Watcher) RemoveWatch(path string) error { +// Remove stops watching for operations on the named file. +func (w *Watcher) Remove(path string) error { return w.removeWatch(path) } diff --git a/fsnotify_linux.go b/fsnotify_linux.go index 407e682..a899e1e 100644 --- a/fsnotify_linux.go +++ b/fsnotify_linux.go @@ -133,7 +133,7 @@ func (w *Watcher) Close() error { // Remove all watches for path := range w.watches { - w.RemoveWatch(path) + w.Remove(path) } // Send "quit" message to the reader goroutine diff --git a/fsnotify_test.go b/fsnotify_test.go index 3f5a648..36357c6 100644 --- a/fsnotify_test.go +++ b/fsnotify_test.go @@ -52,8 +52,8 @@ func newWatcher(t *testing.T) *Watcher { // addWatch adds a watch for a directory func addWatch(t *testing.T, watcher *Watcher, dir string) { - if err := watcher.Watch(dir); err != nil { - t.Fatalf("watcher.Watch(%q) failed: %s", dir, err) + if err := watcher.Add(dir); err != nil { + t.Fatalf("watcher.Add(%q) failed: %s", dir, err) } } @@ -819,7 +819,7 @@ func TestRemovalOfWatch(t *testing.T) { defer watcher.Close() addWatch(t, watcher, testDir) - if err := watcher.RemoveWatch(testDir); err != nil { + if err := watcher.Remove(testDir); err != nil { t.Fatalf("Could not remove the watch: %v\n", err) } @@ -994,7 +994,7 @@ func TestFsnotifyClose(t *testing.T) { testDir := tempMkdir(t) defer os.RemoveAll(testDir) - if err := watcher.Watch(testDir); err == nil { + if err := watcher.Add(testDir); err == nil { t.Fatal("expected error on Watch() after Close(), got nil") } } -- 2.50.1