// license that can be found in the LICENSE file.
/*
-Package inotify implements a wrapper for the Linux inotify system.
+Package fsnotify implements a wrapper for the Linux inotify system.
Example:
- watcher, err := inotify.NewWatcher()
+ watcher, err := fsotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
}
*/
-package inotify
+package fsnotify
import (
"fmt"
)
type Event struct {
- Mask uint32 // Mask of events
- Cookie uint32 // Unique cookie associating related events (for rename(2))
+ mask uint32 // Mask of events
+ cookie uint32 // Unique cookie associating related events (for rename(2))
Name string // File name (optional)
}
// AddWatch adds path to the watched file set.
// The flags are interpreted as described in inotify_add_watch(2).
-func (w *Watcher) AddWatch(path string, flags uint32) os.Error {
+func (w *Watcher) addWatch(path string, flags uint32) os.Error {
if w.isClosed {
return os.NewError("inotify instance already closed")
}
// Watch adds path to the watched file set, watching all events.
func (w *Watcher) Watch(path string) os.Error {
- return w.AddWatch(path, IN_ALL_EVENTS)
+ return w.addWatch(path, IN_ALL_EVENTS)
}
// RemoveWatch removes path from the watched file set.
// Point "raw" to the event in the buffer
raw := (*syscall.InotifyEvent)(unsafe.Pointer(&buf[offset]))
event := new(Event)
- event.Mask = uint32(raw.Mask)
- event.Cookie = uint32(raw.Cookie)
+ event.mask = uint32(raw.Mask)
+ event.cookie = uint32(raw.Cookie)
nameLen := uint32(raw.Len)
// If the event happened to the watched directory or the watched file, the kernel
// doesn't append the filename to the event, but we would like to always fill the
func (e *Event) String() string {
var events string = ""
- m := e.Mask
+ m := e.mask
for _, b := range eventBits {
if m&b.Value != 0 {
m &^= b.Value
events = " == " + events[1:]
}
- return fmt.Sprintf("%q: %#x%s", e.Name, e.Mask, events)
+ return fmt.Sprintf("%q: %#x%s", e.Name, e.mask, events)
}
const (