From efe9224b60035e4c6998205d6cd183673bd6517f Mon Sep 17 00:00:00 2001 From: Nathan Youngman Date: Thu, 19 Jun 2014 21:07:37 -0600 Subject: [PATCH] remove internal watch and removeWatch methods --- CHANGELOG.md | 1 + fsnotify.go | 10 ---------- fsnotify_bsd.go | 16 ++++++++-------- fsnotify_linux.go | 8 ++++---- fsnotify_windows.go | 8 ++++---- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c40479b..f0df1d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Go 1.3+ required on Windows (uses syscall.ERROR_MORE_DATA internally). * [internal] remove cookie from Event struct (unused). * [internal] Event struct has the same definition across every OS. +* [internal] remove internal watch and removeWatch methods. ## v0.11.0 / 2014-06-12 diff --git a/fsnotify.go b/fsnotify.go index 200e61a..cd54051 100644 --- a/fsnotify.go +++ b/fsnotify.go @@ -25,16 +25,6 @@ const ( Chmod ) -// Add starts watching for operations on the named file. -func (w *Watcher) Add(path string) error { - return w.watch(path) -} - -// Remove stops watching for operations on the named file. -func (w *Watcher) Remove(path string) error { - return w.removeWatch(path) -} - // String formats the event e in the form // "filename: REMOVE|WRITE|..." func (e *Event) String() string { diff --git a/fsnotify_bsd.go b/fsnotify_bsd.go index 549b9e4..25823cc 100644 --- a/fsnotify_bsd.go +++ b/fsnotify_bsd.go @@ -115,7 +115,7 @@ func (w *Watcher) Close() error { ws := w.watches w.pmut.Unlock() for path := range ws { - w.removeWatch(path) + w.Remove(path) } return nil @@ -216,16 +216,16 @@ func (w *Watcher) addWatch(path string, flags uint32) error { return nil } -// Watch adds path to the watched file set, watching all events. -func (w *Watcher) watch(path string) error { +// Add starts watching on the named file. +func (w *Watcher) Add(path string) error { w.ewmut.Lock() w.externalWatches[path] = true w.ewmut.Unlock() return w.addWatch(path, sys_NOTE_ALLEVENTS) } -// RemoveWatch removes path from the watched file set. -func (w *Watcher) removeWatch(path string) error { +// Remove stops watching on the named file. +func (w *Watcher) Remove(path string) error { w.wmut.Lock() watchfd, ok := w.watches[path] w.wmut.Unlock() @@ -274,7 +274,7 @@ func (w *Watcher) removeWatch(path string) error { // Since these are internal, not much sense in propagating error // to the user, as that will just confuse them with an error about // a path they did not explicitly watch themselves. - w.removeWatch(p) + w.Remove(p) } } @@ -364,13 +364,13 @@ func (w *Watcher) readEvents() { events = events[1:] if fileEvent.Op&Rename == Rename { - w.removeWatch(fileEvent.Name) + w.Remove(fileEvent.Name) w.femut.Lock() delete(w.fileExists, fileEvent.Name) w.femut.Unlock() } if fileEvent.Op&Remove == Remove { - w.removeWatch(fileEvent.Name) + w.Remove(fileEvent.Name) w.femut.Lock() delete(w.fileExists, fileEvent.Name) w.femut.Unlock() diff --git a/fsnotify_linux.go b/fsnotify_linux.go index 1864824..0d96a32 100644 --- a/fsnotify_linux.go +++ b/fsnotify_linux.go @@ -158,13 +158,13 @@ func (w *Watcher) addWatch(path string, flags uint32) error { return nil } -// Watch adds path to the watched file set, watching all events. -func (w *Watcher) watch(path string) error { +// Add starts watching on the named file. +func (w *Watcher) Add(path string) error { return w.addWatch(path, sys_AGNOSTIC_EVENTS) } -// RemoveWatch removes path from the watched file set. -func (w *Watcher) removeWatch(path string) error { +// Remove stops watching on the named file. +func (w *Watcher) Remove(path string) error { w.mu.Lock() defer w.mu.Unlock() watch, ok := w.watches[path] diff --git a/fsnotify_windows.go b/fsnotify_windows.go index 77ba5e9..a493b4e 100644 --- a/fsnotify_windows.go +++ b/fsnotify_windows.go @@ -163,13 +163,13 @@ func (w *Watcher) AddWatch(path string, flags uint32) error { return <-in.reply } -// Watch adds path to the watched file set, watching all events. -func (w *Watcher) watch(path string) error { +// Add starts watching on the named file. +func (w *Watcher) Add(path string) error { return w.AddWatch(path, sys_FS_ALL_EVENTS) } -// RemoveWatch removes path from the watched file set. -func (w *Watcher) removeWatch(path string) error { +// Remove stops watching on the named file. +func (w *Watcher) Remove(path string) error { in := &input{ op: opRemoveWatch, path: filepath.Clean(path), -- 2.50.1