]> go.fuhry.dev Git - fsnotify.git/commitdiff
Make ./path and path equivalent.
authorSoge Zhang <zhssoge@gmail.com>
Sun, 17 Aug 2014 16:28:19 +0000 (00:28 +0800)
committerNathan Youngman <git@nathany.com>
Sun, 17 Aug 2014 21:22:53 +0000 (15:22 -0600)
Using filepath.Clean (BSD and Linux).

fsnotify_bsd.go
fsnotify_linux.go

index 5e02974fba26db1c6cdfcf1d3fcaed887fbc7154..096fccf4eefacd2c9fc331b7c1dd041390a8c51d 100644 (file)
@@ -114,6 +114,7 @@ func (w *Watcher) Close() error {
 // addWatch adds path to the watched file set.
 // The flags are interpreted as described in kevent(2).
 func (w *Watcher) addWatch(path string, flags uint32) error {
+       path = filepath.Clean(path)
        w.mu.Lock()
        if w.isClosed {
                w.mu.Unlock()
@@ -216,6 +217,7 @@ func (w *Watcher) Add(name string) error {
 
 // Remove stops watching the the named file or directory (non-recursively).
 func (w *Watcher) Remove(name string) error {
+       name = filepath.Clean(name)
        w.wmut.Lock()
        watchfd, ok := w.watches[name]
        w.wmut.Unlock()
index 51aca18903b0d27bde1e7b30c9784063a2fc86a8..29c2868e8f4513be4dd823a2316d591eac3e358e 100644 (file)
@@ -8,6 +8,7 @@ import (
        "errors"
        "fmt"
        "os"
+       "path/filepath"
        "strings"
        "sync"
        "syscall"
@@ -97,6 +98,7 @@ func (w *Watcher) Close() error {
 
 // Add starts watching the named file or directory (non-recursively).
 func (w *Watcher) Add(name string) error {
+       name = filepath.Clean(name)
        if w.isClosed {
                return errors.New("inotify instance already closed")
        }
@@ -125,6 +127,7 @@ func (w *Watcher) Add(name string) error {
 
 // Remove stops watching the the named file or directory (non-recursively).
 func (w *Watcher) Remove(name string) error {
+       name = filepath.Clean(name)
        w.mu.Lock()
        defer w.mu.Unlock()
        watch, ok := w.watches[name]