)
type Event struct {
- Name string // Relative path to the file/directory.
- Op Op // Platform-independent mask.
- cookie uint32 // Unique cookie associating related events (for rename(2))
+ Name string // Relative path to the file/directory.
+ Op Op // Platform-independent mask.
}
-func newEvent(name string, mask uint32, cookie uint32) *Event {
- e := &Event{Name: name, cookie: cookie}
+func newEvent(name string, mask uint32) *Event {
+ e := &Event{Name: name}
if mask&sys_IN_CREATE == sys_IN_CREATE || mask&sys_IN_MOVED_TO == sys_IN_MOVED_TO {
e.Op |= Create
}
raw := (*syscall.InotifyEvent)(unsafe.Pointer(&buf[offset]))
mask := uint32(raw.Mask)
- 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
name += "/" + strings.TrimRight(string(bytes[0:nameLen]), "\000")
}
- event := newEvent(name, mask, cookie)
+ event := newEvent(name, mask)
// Send the events that are not ignored on the events channel
if !event.ignoreLinux(mask) {
// Event is the type of the notification messages
// received on the watcher's Events channel.
type Event struct {
- Name string // Relative path to the file/directory.
- Op Op // Platform-independent bitmask.
- cookie uint32 // Unique cookie associating related events (for rename)
+ Name string // Relative path to the file/directory.
+ Op Op // Platform-independent bitmask.
}
func newEvent(name string, mask uint32) *Event {
Errors chan error // Errors are sent on this channel
isClosed bool // Set to true when Close() is first called
quit chan chan<- error
- cookie uint32
}
// NewWatcher creates and returns a Watcher.
return false
}
event := newEvent(name, uint32(mask))
- if mask&sys_FS_MOVE != 0 {
- if mask&sys_FS_MOVED_FROM != 0 {
- w.cookie++
- }
- event.cookie = w.cookie
- }
select {
case ch := <-w.quit:
w.quit <- ch