]> go.fuhry.dev Git - fsnotify.git/commitdiff
Add/Remove watches
authorNathan Youngman <git@nathany.com>
Fri, 13 Jun 2014 03:30:02 +0000 (21:30 -0600)
committerNathan Youngman <git@nathany.com>
Fri, 13 Jun 2014 03:30:02 +0000 (21:30 -0600)
example_test.go
fsnotify.go
fsnotify_linux.go
fsnotify_test.go

index f0b33a018978fc35011d12fe777a1e518ce8fae5..e8a3b07bb617ccea4967e8f78e4422ec9cf593a4 100644 (file)
@@ -27,7 +27,7 @@ func ExampleNewWatcher() {
                }
        }()
 
-       err = watcher.Watch("/tmp/foo")
+       err = watcher.Add("/tmp/foo")
        if err != nil {
                log.Fatal(err)
        }
index 2622de407100589494e577432546770dc267bc8f..7c27f6ae661d862cd9a567467db328ad9695df5b 100644 (file)
@@ -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)
 }
 
index 407e6827493ca632397269e2462f6f23e09fce42..a899e1ecd8ff9d96da39b670926a50541464b50c 100644 (file)
@@ -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
index 3f5a6487ffe3462c891de982352cc6a91391e713..36357c6a91d5cc0c77815e817766ed24f7f97096 100644 (file)
@@ -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")
        }
 }