From 6ea290cfa9f266c497349c9d6b53ed9ab2242489 Mon Sep 17 00:00:00 2001 From: Chris Howey Date: Wed, 29 May 2013 19:03:21 -0500 Subject: [PATCH] BSD - Make syscall flags internal --- fsnotify_bsd.go | 36 ++++++++++++++++++------------------ fsnotify_open_bsd.go | 2 +- fsnotify_open_darwin.go | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/fsnotify_bsd.go b/fsnotify_bsd.go index 4d15a11..13c97cc 100644 --- a/fsnotify_bsd.go +++ b/fsnotify_bsd.go @@ -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 ) - 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 diff --git a/fsnotify_open_bsd.go b/fsnotify_open_bsd.go index bb4faed..2038d3a 100644 --- a/fsnotify_open_bsd.go +++ b/fsnotify_open_bsd.go @@ -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 diff --git a/fsnotify_open_darwin.go b/fsnotify_open_darwin.go index 859ee2c..be30f14 100644 --- a/fsnotify_open_darwin.go +++ b/fsnotify_open_darwin.go @@ -8,4 +8,4 @@ package fsnotify import "syscall" -const OPEN_FLAGS = syscall.O_EVTONLY +const open_FLAGS = syscall.O_EVTONLY -- 2.50.1