From 7f116452079e89b7a82c216ce6dc9133487f8cd3 Mon Sep 17 00:00:00 2001 From: Chris Howey Date: Sat, 1 Jun 2013 16:35:37 -0500 Subject: [PATCH] Place const declarations to top of file --- fsnotify_bsd.go | 34 +++++++++---------- fsnotify_linux.go | 80 ++++++++++++++++++++++----------------------- fsnotify_windows.go | 48 +++++++++++++-------------- 3 files changed, 81 insertions(+), 81 deletions(-) diff --git a/fsnotify_bsd.go b/fsnotify_bsd.go index 13c97cc..a30b1ab 100644 --- a/fsnotify_bsd.go +++ b/fsnotify_bsd.go @@ -16,6 +16,23 @@ import ( "syscall" ) +const ( + // Flags (from ) + 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 + 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 +) + type FileEvent struct { mask uint32 // Mask of events Name string // File name (optional) @@ -447,20 +464,3 @@ func (w *Watcher) sendDirectoryChangeEvents(dirPath string) { } w.watchDirectoryFiles(dirPath) } - -const ( - // Flags (from ) - 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 - 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_linux.go b/fsnotify_linux.go index 02c9355..0714e12 100644 --- a/fsnotify_linux.go +++ b/fsnotify_linux.go @@ -16,6 +16,46 @@ import ( "unsafe" ) +const ( + // Options for inotify_init() are not exported + // sys_IN_CLOEXEC uint32 = syscall.IN_CLOEXEC + // sys_IN_NONBLOCK uint32 = syscall.IN_NONBLOCK + + // Options for AddWatch + sys_IN_DONT_FOLLOW uint32 = syscall.IN_DONT_FOLLOW + sys_IN_ONESHOT uint32 = syscall.IN_ONESHOT + sys_IN_ONLYDIR uint32 = syscall.IN_ONLYDIR + + // The "sys_IN_MASK_ADD" option is not exported, as AddWatch + // adds it automatically, if there is already a watch for the given path + // sys_IN_MASK_ADD uint32 = syscall.IN_MASK_ADD + + // Events + sys_IN_ACCESS uint32 = syscall.IN_ACCESS + sys_IN_ALL_EVENTS uint32 = syscall.IN_ALL_EVENTS + sys_IN_ATTRIB uint32 = syscall.IN_ATTRIB + sys_IN_CLOSE uint32 = syscall.IN_CLOSE + sys_IN_CLOSE_NOWRITE uint32 = syscall.IN_CLOSE_NOWRITE + sys_IN_CLOSE_WRITE uint32 = syscall.IN_CLOSE_WRITE + sys_IN_CREATE uint32 = syscall.IN_CREATE + sys_IN_DELETE uint32 = syscall.IN_DELETE + sys_IN_DELETE_SELF uint32 = syscall.IN_DELETE_SELF + sys_IN_MODIFY uint32 = syscall.IN_MODIFY + sys_IN_MOVE uint32 = syscall.IN_MOVE + sys_IN_MOVED_FROM uint32 = syscall.IN_MOVED_FROM + sys_IN_MOVED_TO uint32 = syscall.IN_MOVED_TO + sys_IN_MOVE_SELF uint32 = syscall.IN_MOVE_SELF + sys_IN_OPEN uint32 = syscall.IN_OPEN + + sys_AGNOSTIC_EVENTS = sys_IN_MOVED_TO | sys_IN_MOVED_FROM | sys_IN_CREATE | sys_IN_ATTRIB | sys_IN_MODIFY | sys_IN_MOVE_SELF | sys_IN_DELETE | sys_IN_DELETE_SELF + + // Special events + sys_IN_ISDIR uint32 = syscall.IN_ISDIR + sys_IN_IGNORED uint32 = syscall.IN_IGNORED + sys_IN_Q_OVERFLOW uint32 = syscall.IN_Q_OVERFLOW + sys_IN_UNMOUNT uint32 = syscall.IN_UNMOUNT +) + type FileEvent struct { mask uint32 // Mask of events cookie uint32 // Unique cookie associating related events (for rename(2)) @@ -255,43 +295,3 @@ func (e *FileEvent) ignoreLinux() bool { } return false } - -const ( - // Options for inotify_init() are not exported - // sys_IN_CLOEXEC uint32 = syscall.IN_CLOEXEC - // sys_IN_NONBLOCK uint32 = syscall.IN_NONBLOCK - - // Options for AddWatch - sys_IN_DONT_FOLLOW uint32 = syscall.IN_DONT_FOLLOW - sys_IN_ONESHOT uint32 = syscall.IN_ONESHOT - sys_IN_ONLYDIR uint32 = syscall.IN_ONLYDIR - - // The "sys_IN_MASK_ADD" option is not exported, as AddWatch - // adds it automatically, if there is already a watch for the given path - // sys_IN_MASK_ADD uint32 = syscall.IN_MASK_ADD - - // Events - sys_IN_ACCESS uint32 = syscall.IN_ACCESS - sys_IN_ALL_EVENTS uint32 = syscall.IN_ALL_EVENTS - sys_IN_ATTRIB uint32 = syscall.IN_ATTRIB - sys_IN_CLOSE uint32 = syscall.IN_CLOSE - sys_IN_CLOSE_NOWRITE uint32 = syscall.IN_CLOSE_NOWRITE - sys_IN_CLOSE_WRITE uint32 = syscall.IN_CLOSE_WRITE - sys_IN_CREATE uint32 = syscall.IN_CREATE - sys_IN_DELETE uint32 = syscall.IN_DELETE - sys_IN_DELETE_SELF uint32 = syscall.IN_DELETE_SELF - sys_IN_MODIFY uint32 = syscall.IN_MODIFY - sys_IN_MOVE uint32 = syscall.IN_MOVE - sys_IN_MOVED_FROM uint32 = syscall.IN_MOVED_FROM - sys_IN_MOVED_TO uint32 = syscall.IN_MOVED_TO - sys_IN_MOVE_SELF uint32 = syscall.IN_MOVE_SELF - sys_IN_OPEN uint32 = syscall.IN_OPEN - - sys_AGNOSTIC_EVENTS = sys_IN_MOVED_TO | sys_IN_MOVED_FROM | sys_IN_CREATE | sys_IN_ATTRIB | sys_IN_MODIFY | sys_IN_MOVE_SELF | sys_IN_DELETE | sys_IN_DELETE_SELF - - // Special events - sys_IN_ISDIR uint32 = syscall.IN_ISDIR - sys_IN_IGNORED uint32 = syscall.IN_IGNORED - sys_IN_Q_OVERFLOW uint32 = syscall.IN_Q_OVERFLOW - sys_IN_UNMOUNT uint32 = syscall.IN_UNMOUNT -) diff --git a/fsnotify_windows.go b/fsnotify_windows.go index 429ca0a..8245130 100644 --- a/fsnotify_windows.go +++ b/fsnotify_windows.go @@ -17,6 +17,30 @@ import ( "unsafe" ) +const ( + // Options for AddWatch + sys_FS_ONESHOT = 0x80000000 + sys_FS_ONLYDIR = 0x1000000 + + // Events + sys_FS_ACCESS = 0x1 + sys_FS_ALL_EVENTS = 0xfff + sys_FS_ATTRIB = 0x4 + sys_FS_CLOSE = 0x18 + sys_FS_CREATE = 0x100 + sys_FS_DELETE = 0x200 + sys_FS_DELETE_SELF = 0x400 + sys_FS_MODIFY = 0x2 + sys_FS_MOVE = 0xc0 + sys_FS_MOVED_FROM = 0x40 + sys_FS_MOVED_TO = 0x80 + sys_FS_MOVE_SELF = 0x800 + + // Special events + sys_FS_IGNORED = 0x8000 + sys_FS_Q_OVERFLOW = 0x4000 +) + // Event is the type of the notification messages // received on the watcher's Event channel. type FileEvent struct { @@ -547,27 +571,3 @@ func toFSnotifyFlags(action uint32) uint64 { } return 0 } - -const ( - // Options for AddWatch - sys_FS_ONESHOT = 0x80000000 - sys_FS_ONLYDIR = 0x1000000 - - // Events - sys_FS_ACCESS = 0x1 - sys_FS_ALL_EVENTS = 0xfff - sys_FS_ATTRIB = 0x4 - sys_FS_CLOSE = 0x18 - sys_FS_CREATE = 0x100 - sys_FS_DELETE = 0x200 - sys_FS_DELETE_SELF = 0x400 - sys_FS_MODIFY = 0x2 - sys_FS_MOVE = 0xc0 - sys_FS_MOVED_FROM = 0x40 - sys_FS_MOVED_TO = 0x80 - sys_FS_MOVE_SELF = 0x800 - - // Special events - sys_FS_IGNORED = 0x8000 - sys_FS_Q_OVERFLOW = 0x4000 -) -- 2.50.1