* 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
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 {
ws := w.watches
w.pmut.Unlock()
for path := range ws {
- w.removeWatch(path)
+ w.Remove(path)
}
return nil
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()
// 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)
}
}
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()
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]
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),