]> go.fuhry.dev Git - fsnotify.git/commitdiff
BSD - Make syscall flags internal
authorChris Howey <chris@howey.me>
Thu, 30 May 2013 00:03:21 +0000 (19:03 -0500)
committerChris Howey <chris@howey.me>
Thu, 30 May 2013 00:03:21 +0000 (19:03 -0500)
fsnotify_bsd.go
fsnotify_open_bsd.go
fsnotify_open_darwin.go

index 4d15a1134856f08ddf865ff513e0cce68d11c018..13c97ccd6d85e1176ac7aa29132b4a7aefcb8473 100644 (file)
@@ -26,15 +26,15 @@ type FileEvent struct {
 func (e *FileEvent) IsCreate() bool { return e.create }
 
 // IsDelete reports whether the FileEvent was triggerd by a delete
-func (e *FileEvent) IsDelete() bool { return (e.mask & NOTE_DELETE) == NOTE_DELETE }
+func (e *FileEvent) IsDelete() bool { return (e.mask & sys_NOTE_DELETE) == sys_NOTE_DELETE }
 
 // IsModify reports whether the FileEvent was triggerd by a file modification
 func (e *FileEvent) IsModify() bool {
-       return ((e.mask&NOTE_WRITE) == NOTE_WRITE || (e.mask&NOTE_ATTRIB) == NOTE_ATTRIB)
+       return ((e.mask&sys_NOTE_WRITE) == sys_NOTE_WRITE || (e.mask&sys_NOTE_ATTRIB) == sys_NOTE_ATTRIB)
 }
 
 // IsRename reports whether the FileEvent was triggerd by a change name
-func (e *FileEvent) IsRename() bool { return (e.mask & NOTE_RENAME) == NOTE_RENAME }
+func (e *FileEvent) IsRename() bool { return (e.mask & sys_NOTE_RENAME) == sys_NOTE_RENAME }
 
 type Watcher struct {
        mu            sync.Mutex          // Mutex for the Watcher itself.
@@ -152,7 +152,7 @@ func (w *Watcher) addWatch(path string, flags uint32) error {
                        }
                }
 
-               fd, errno := syscall.Open(path, OPEN_FLAGS, 0700)
+               fd, errno := syscall.Open(path, open_FLAGS, 0700)
                if fd == -1 {
                        return errno
                }
@@ -171,8 +171,8 @@ func (w *Watcher) addWatch(path string, flags uint32) error {
        w.pmut.Lock()
        w.enmut.Lock()
        if w.finfo[watchfd].IsDir() &&
-               (flags&NOTE_WRITE) == NOTE_WRITE &&
-               (!found || (w.enFlags[path]&NOTE_WRITE) != NOTE_WRITE) {
+               (flags&sys_NOTE_WRITE) == sys_NOTE_WRITE &&
+               (!found || (w.enFlags[path]&sys_NOTE_WRITE) != sys_NOTE_WRITE) {
                watchDir = true
        }
        w.enmut.Unlock()
@@ -207,7 +207,7 @@ func (w *Watcher) addWatch(path string, flags uint32) error {
 
 // Watch adds path to the watched file set, watching all events.
 func (w *Watcher) watch(path string) error {
-       return w.addWatch(path, NOTE_ALLEVENTS)
+       return w.addWatch(path, sys_NOTE_ALLEVENTS)
 }
 
 // RemoveWatch removes path from the watched file set.
@@ -308,7 +308,7 @@ func (w *Watcher) readEvents() {
                                // receive the delete event
                                if _, err := os.Lstat(fileEvent.Name); os.IsNotExist(err) {
                                        // mark is as delete event
-                                       fileEvent.mask |= NOTE_DELETE
+                                       fileEvent.mask |= sys_NOTE_DELETE
                                }
                        }
 
@@ -378,7 +378,7 @@ func (w *Watcher) watchDirectoryFiles(dirPath string) error {
 
                if fileInfo.IsDir() == false {
                        // Watch file to mimic linux fsnotify
-                       e := w.addWatch(filePath, NOTE_ALLEVENTS)
+                       e := w.addWatch(filePath, sys_NOTE_ALLEVENTS)
                        if e != nil {
                                return e
                        }
@@ -388,7 +388,7 @@ func (w *Watcher) watchDirectoryFiles(dirPath string) error {
                        w.enmut.Lock()
                        currFlags, found := w.enFlags[filePath]
                        w.enmut.Unlock()
-                       var newFlags uint32 = NOTE_DELETE
+                       var newFlags uint32 = sys_NOTE_DELETE
                        if found {
                                newFlags |= currFlags
                        }
@@ -450,16 +450,16 @@ func (w *Watcher) sendDirectoryChangeEvents(dirPath string) {
 
 const (
        // Flags (from <sys/event.h>)
-       NOTE_DELETE = 0x0001 /* vnode was removed */
-       NOTE_WRITE  = 0x0002 /* data contents changed */
-       NOTE_EXTEND = 0x0004 /* size increased */
-       NOTE_ATTRIB = 0x0008 /* attributes changed */
-       NOTE_LINK   = 0x0010 /* link count changed */
-       NOTE_RENAME = 0x0020 /* vnode was renamed */
-       NOTE_REVOKE = 0x0040 /* vnode access was revoked */
+       sys_NOTE_DELETE = 0x0001 /* vnode was removed */
+       sys_NOTE_WRITE  = 0x0002 /* data contents changed */
+       sys_NOTE_EXTEND = 0x0004 /* size increased */
+       sys_NOTE_ATTRIB = 0x0008 /* attributes changed */
+       sys_NOTE_LINK   = 0x0010 /* link count changed */
+       sys_NOTE_RENAME = 0x0020 /* vnode was renamed */
+       sys_NOTE_REVOKE = 0x0040 /* vnode access was revoked */
 
        // Watch all events
-       NOTE_ALLEVENTS = NOTE_DELETE | NOTE_WRITE | NOTE_ATTRIB | NOTE_RENAME
+       sys_NOTE_ALLEVENTS = sys_NOTE_DELETE | sys_NOTE_WRITE | sys_NOTE_ATTRIB | sys_NOTE_RENAME
 
        // Block for 100 ms on each call to kevent
        keventWaitTime = 100e6
index bb4faed598e9ebb1449e6ff38aaa47e052b6e1eb..2038d3ab340d3638fbc6fd0c6aa024cfd36b5804 100644 (file)
@@ -8,4 +8,4 @@ package fsnotify
 
 import "syscall"
 
-const OPEN_FLAGS = syscall.O_NONBLOCK | syscall.O_RDONLY
+const open_FLAGS = syscall.O_NONBLOCK | syscall.O_RDONLY
index 859ee2c503003688080293d48ae43590fb5aa87a..be30f14f04fccb4cf12e155b1f5f28c2c0edcea3 100644 (file)
@@ -8,4 +8,4 @@ package fsnotify
 
 import "syscall"
 
-const OPEN_FLAGS = syscall.O_EVTONLY
+const open_FLAGS = syscall.O_EVTONLY