]> go.fuhry.dev Git - fsnotify.git/commitdiff
Renamed FileEvent struct to Event.
authorNathan Youngman <git@nathany.com>
Fri, 13 Jun 2014 03:48:25 +0000 (21:48 -0600)
committerNathan Youngman <git@nathany.com>
Fri, 13 Jun 2014 03:48:25 +0000 (21:48 -0600)
fsnotify.go
fsnotify_bsd.go
fsnotify_linux.go
fsnotify_windows.go

index 7c27f6ae661d862cd9a567467db328ad9695df5b..8f51a3c944480f552799ca5f22b536be058d630d 100644 (file)
@@ -19,7 +19,7 @@ func (w *Watcher) Remove(path string) error {
 
 // String formats the event e in the form
 // "filename: DELETE|MODIFY|..."
-func (e *FileEvent) String() string {
+func (e *Event) String() string {
        var events string = ""
 
        if e.IsCreate() {
index b04c25307f1306e21bc74749b66ac329238a0cc8..752bbf52bca9a1b9eb1cc856b01a07156e8af0d2 100644 (file)
@@ -33,28 +33,28 @@ const (
        keventWaitTime = 100e6
 )
 
-type FileEvent struct {
+type Event struct {
        mask   uint32 // Mask of events
        Name   string // File name (optional)
        create bool   // set by fsnotify package if found new file
 }
 
-// IsCreate reports whether the FileEvent was triggered by a creation
-func (e *FileEvent) IsCreate() bool { return e.create }
+// IsCreate reports whether the Event was triggered by a creation
+func (e *Event) IsCreate() bool { return e.create }
 
-// IsDelete reports whether the FileEvent was triggered by a delete
-func (e *FileEvent) IsDelete() bool { return (e.mask & sys_NOTE_DELETE) == sys_NOTE_DELETE }
+// IsDelete reports whether the Event was triggered by a delete
+func (e *Event) IsDelete() bool { return (e.mask & sys_NOTE_DELETE) == sys_NOTE_DELETE }
 
-// IsModify reports whether the FileEvent was triggered by a file modification
-func (e *FileEvent) IsModify() bool {
+// IsModify reports whether the Event was triggered by a file modification
+func (e *Event) IsModify() bool {
        return ((e.mask&sys_NOTE_WRITE) == sys_NOTE_WRITE || (e.mask&sys_NOTE_ATTRIB) == sys_NOTE_ATTRIB)
 }
 
-// IsRename reports whether the FileEvent was triggered by a change name
-func (e *FileEvent) IsRename() bool { return (e.mask & sys_NOTE_RENAME) == sys_NOTE_RENAME }
+// IsRename reports whether the Event was triggered by a change name
+func (e *Event) 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.
-func (e *FileEvent) IsAttrib() bool {
+// IsAttrib reports whether the Event was triggered by a change in the file metadata.
+func (e *Event) IsAttrib() bool {
        return (e.mask & sys_NOTE_ATTRIB) == sys_NOTE_ATTRIB
 }
 
@@ -73,7 +73,7 @@ type Watcher struct {
        externalWatches map[string]bool     // Map of watches added by user of the library.
        ewmut           sync.Mutex          // Protects access to externalWatches.
        Errors          chan error          // Errors are sent on this channel
-       Events          chan *FileEvent     // Events are returned on this channel
+       Events          chan *Event         // Events are returned on this channel
        done            chan bool           // Channel for sending a "quit message" to the reader goroutine
        isClosed        bool                // Set to true when Close() is first called
 }
@@ -92,7 +92,7 @@ func NewWatcher() (*Watcher, error) {
                finfo:           make(map[int]os.FileInfo),
                fileExists:      make(map[string]bool),
                externalWatches: make(map[string]bool),
-               Events:          make(chan *FileEvent),
+               Events:          make(chan *Event),
                Errors:          make(chan error),
                done:            make(chan bool, 1),
        }
@@ -337,7 +337,7 @@ func (w *Watcher) readEvents() {
 
                // Flush the events we received to the events channel
                for len(events) > 0 {
-                       fileEvent := new(FileEvent)
+                       fileEvent := new(Event)
                        watchEvent := &events[0]
                        fileEvent.mask = uint32(watchEvent.Fflags)
                        w.pmut.Lock()
@@ -459,7 +459,7 @@ func (w *Watcher) sendDirectoryChangeEvents(dirPath string) {
                w.femut.Unlock()
                if !doesExist {
                        // Send create event
-                       fileEvent := new(FileEvent)
+                       fileEvent := new(Event)
                        fileEvent.Name = filePath
                        fileEvent.create = true
                        w.Events <- fileEvent
index 1d9319ab664ed65c546acaa106f293b9b99c43dc..14c028fac7a3020d3355cfd53142a6233c932eae 100644 (file)
@@ -56,34 +56,34 @@ const (
        sys_IN_UNMOUNT    uint32 = syscall.IN_UNMOUNT
 )
 
-type FileEvent struct {
+type Event struct {
        mask   uint32 // Mask of events
        cookie uint32 // Unique cookie associating related events (for rename(2))
        Name   string // File name (optional)
 }
 
-// IsCreate reports whether the FileEvent was triggered by a creation
-func (e *FileEvent) IsCreate() bool {
+// IsCreate reports whether the Event was triggered by a creation
+func (e *Event) IsCreate() bool {
        return (e.mask&sys_IN_CREATE) == sys_IN_CREATE || (e.mask&sys_IN_MOVED_TO) == sys_IN_MOVED_TO
 }
 
-// IsDelete reports whether the FileEvent was triggered by a delete
-func (e *FileEvent) IsDelete() bool {
+// IsDelete reports whether the Event was triggered by a delete
+func (e *Event) IsDelete() bool {
        return (e.mask&sys_IN_DELETE_SELF) == sys_IN_DELETE_SELF || (e.mask&sys_IN_DELETE) == sys_IN_DELETE
 }
 
-// IsModify reports whether the FileEvent was triggered by a file modification or attribute change
-func (e *FileEvent) IsModify() bool {
+// IsModify reports whether the Event was triggered by a file modification or attribute change
+func (e *Event) IsModify() bool {
        return ((e.mask&sys_IN_MODIFY) == sys_IN_MODIFY || (e.mask&sys_IN_ATTRIB) == sys_IN_ATTRIB)
 }
 
-// IsRename reports whether the FileEvent was triggered by a change name
-func (e *FileEvent) IsRename() bool {
+// IsRename reports whether the Event was triggered by a change name
+func (e *Event) IsRename() bool {
        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.
-func (e *FileEvent) IsAttrib() bool {
+// IsAttrib reports whether the Event was triggered by a change in the file metadata.
+func (e *Event) IsAttrib() bool {
        return (e.mask & sys_IN_ATTRIB) == sys_IN_ATTRIB
 }
 
@@ -98,7 +98,7 @@ type Watcher struct {
        watches  map[string]*watch // Map of inotify watches (key: path)
        paths    map[int]string    // Map of watched paths (key: watch descriptor)
        Errors   chan error        // Errors are sent on this channel
-       Events   chan *FileEvent   // Events are returned on this channel
+       Events   chan *Event       // Events are returned on this channel
        done     chan bool         // Channel for sending a "quit message" to the reader goroutine
        isClosed bool              // Set to true when Close() is first called
 }
@@ -113,7 +113,7 @@ func NewWatcher() (*Watcher, error) {
                fd:      fd,
                watches: make(map[string]*watch),
                paths:   make(map[int]string),
-               Events:  make(chan *FileEvent),
+               Events:  make(chan *Event),
                Errors:  make(chan error),
                done:    make(chan bool, 1),
        }
@@ -235,7 +235,7 @@ func (w *Watcher) readEvents() {
                for offset <= uint32(n-syscall.SizeofInotifyEvent) {
                        // Point "raw" to the event in the buffer
                        raw := (*syscall.InotifyEvent)(unsafe.Pointer(&buf[offset]))
-                       event := new(FileEvent)
+                       event := new(Event)
                        event.mask = uint32(raw.Mask)
                        event.cookie = uint32(raw.Cookie)
                        nameLen := uint32(raw.Len)
@@ -267,7 +267,7 @@ func (w *Watcher) readEvents() {
 // Certain types of events can be "ignored" and not sent over the Events
 // channel. Such as events marked ignore by the kernel, or MODIFY events
 // against files that do not exist.
-func (e *FileEvent) ignoreLinux() bool {
+func (e *Event) ignoreLinux() bool {
        // Ignore anything the inotify API says to ignore
        if e.mask&sys_IN_IGNORED == sys_IN_IGNORED {
                return true
index 8d6649f3cc8c017d81f4b5b287b710aca959ad3f..f74b8eba2c09b670c8ee2ab64e16cdbe2e0140d2 100644 (file)
@@ -48,32 +48,32 @@ const (
 
 // Event is the type of the notification messages
 // received on the watcher's Events channel.
-type FileEvent struct {
+type Event struct {
        mask   uint32 // Mask of events
        cookie uint32 // Unique cookie associating related events (for rename)
        Name   string // File name (optional)
 }
 
-// IsCreate reports whether the FileEvent was triggered by a creation
-func (e *FileEvent) IsCreate() bool { return (e.mask & sys_FS_CREATE) == sys_FS_CREATE }
+// IsCreate reports whether the Event was triggered by a creation
+func (e *Event) IsCreate() bool { return (e.mask & sys_FS_CREATE) == sys_FS_CREATE }
 
-// IsDelete reports whether the FileEvent was triggered by a delete
-func (e *FileEvent) IsDelete() bool {
+// IsDelete reports whether the Event was triggered by a delete
+func (e *Event) IsDelete() bool {
        return ((e.mask&sys_FS_DELETE) == sys_FS_DELETE || (e.mask&sys_FS_DELETE_SELF) == sys_FS_DELETE_SELF)
 }
 
-// IsModify reports whether the FileEvent was triggered by a file modification or attribute change
-func (e *FileEvent) IsModify() bool {
+// IsModify reports whether the Event was triggered by a file modification or attribute change
+func (e *Event) IsModify() bool {
        return ((e.mask&sys_FS_MODIFY) == sys_FS_MODIFY || (e.mask&sys_FS_ATTRIB) == sys_FS_ATTRIB)
 }
 
-// IsRename reports whether the FileEvent was triggered by a change name
-func (e *FileEvent) IsRename() bool {
+// IsRename reports whether the Event was triggered by a change name
+func (e *Event) IsRename() bool {
        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.
-func (e *FileEvent) IsAttrib() bool {
+// IsAttrib reports whether the Event was triggered by a change in the file metadata.
+func (e *Event) IsAttrib() bool {
        return (e.mask & sys_FS_ATTRIB) == sys_FS_ATTRIB
 }
 
@@ -115,13 +115,13 @@ type watchMap map[uint32]indexMap
 // A Watcher waits for and receives event notifications
 // for a specific set of files and directories.
 type Watcher struct {
-       mu       sync.Mutex      // Map access
-       port     syscall.Handle  // Handle to completion port
-       watches  watchMap        // Map of watches (key: i-number)
-       input    chan *input     // Inputs to the reader are sent on this channel
-       Events   chan *FileEvent // Events are returned on this channel
-       Errors   chan error      // Errors are sent on this channel
-       isClosed bool            // Set to true when Close() is first called
+       mu       sync.Mutex     // Map access
+       port     syscall.Handle // Handle to completion port
+       watches  watchMap       // Map of watches (key: i-number)
+       input    chan *input    // Inputs to the reader are sent on this channel
+       Events   chan *Event    // Events are returned on this channel
+       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
 }
@@ -136,7 +136,7 @@ func NewWatcher() (*Watcher, error) {
                port:    port,
                watches: make(watchMap),
                input:   make(chan *input, 1),
-               Events:  make(chan *FileEvent, 50),
+               Events:  make(chan *Event, 50),
                Errors:  make(chan error),
                quit:    make(chan chan<- error, 1),
        }
@@ -469,7 +469,7 @@ func (w *Watcher) readEvents() {
                var offset uint32
                for {
                        if n == 0 {
-                               w.Events <- &FileEvent{mask: sys_FS_Q_OVERFLOW}
+                               w.Events <- &Event{mask: sys_FS_Q_OVERFLOW}
                                w.Errors <- errors.New("short read in readEvents()")
                                break
                        }
@@ -543,7 +543,7 @@ func (w *Watcher) sendEvent(name string, mask uint64) bool {
        if mask == 0 {
                return false
        }
-       event := &FileEvent{mask: uint32(mask), Name: name}
+       event := &Event{mask: uint32(mask), Name: name}
        if mask&sys_FS_MOVE != 0 {
                if mask&sys_FS_MOVED_FROM != 0 {
                        w.cookie++