This IsAttrib function can be used to distinguish events that only
concern a file's metadata (eg. atime, mtime etc.).
events += "|" + "RENAME"
}
+ if e.IsAttrib() {
+ events += "|" + "ATTRIB"
+ }
+
if len(events) > 0 {
events = events[1:]
}
// IsRename reports whether the FileEvent was triggerd by a change name
func (e *FileEvent) IsRename() bool { return (e.mask & sys_NOTE_RENAME) == sys_NOTE_RENAME }
+// IsAttrib reports whether the FileEvent was triggered by a change in the file metadata (eg.
+// atime, mtime etc.)
+func (e *FileEvent) IsAttrib() bool {
+ return (e.mask & sys_NOTE_ATTRIB) == sys_NOTE_ATTRIB
+}
+
type Watcher struct {
mu sync.Mutex // Mutex for the Watcher itself.
kq int // File descriptor (as returned by the kqueue() syscall)
return ((e.mask&sys_IN_MOVE_SELF) == sys_IN_MOVE_SELF || (e.mask&sys_IN_MOVED_FROM) == sys_IN_MOVED_FROM)
}
+// IsAttrib reports whether the FileEvent was triggered by a change in the file metadata (eg.
+// atime, mtime etc.)
+func (e *FileEvent) IsAttrib() bool {
+ return (e.mask & sys_IN_ATTRIB) == sys_IN_ATTRIB
+}
+
type watch struct {
wd uint32 // Watch descriptor (as returned by the inotify_add_watch() syscall)
flags uint32 // inotify flags of this watch (see inotify(7) for the list of valid flags)
return ((e.mask&sys_FS_MOVE) == sys_FS_MOVE || (e.mask&sys_FS_MOVE_SELF) == sys_FS_MOVE_SELF || (e.mask&sys_FS_MOVED_FROM) == sys_FS_MOVED_FROM || (e.mask&sys_FS_MOVED_TO) == sys_FS_MOVED_TO)
}
+// IsAttrib reports whether the FileEvent was triggered by a change in the file metadata (eg.
+// atime, mtime etc.)
+func (e *FileEvent) IsAttrib() bool {
+ return (e.mask & sys_FS_ATTRIB) == sys_FS_ATTRIB
+}
+
const (
opAddWatch = iota
opRemoveWatch