| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
package notify |
| 8 |
|
| 9 |
import "golang.org/x/sys/unix" |
| 10 |
|
| 11 |
|
| 12 |
const ( |
| 13 |
osSpecificCreate Event = 0x100000 << iota |
| 14 |
osSpecificRemove |
| 15 |
osSpecificWrite |
| 16 |
osSpecificRename |
| 17 |
|
| 18 |
|
| 19 |
recursive |
| 20 |
|
| 21 |
|
| 22 |
omit |
| 23 |
) |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
const ( |
| 28 |
InAccess = Event(unix.IN_ACCESS) |
| 29 |
InModify = Event(unix.IN_MODIFY) |
| 30 |
InAttrib = Event(unix.IN_ATTRIB) |
| 31 |
InCloseWrite = Event(unix.IN_CLOSE_WRITE) |
| 32 |
InCloseNowrite = Event(unix.IN_CLOSE_NOWRITE) |
| 33 |
InOpen = Event(unix.IN_OPEN) |
| 34 |
InMovedFrom = Event(unix.IN_MOVED_FROM) |
| 35 |
InMovedTo = Event(unix.IN_MOVED_TO) |
| 36 |
InCreate = Event(unix.IN_CREATE) |
| 37 |
InDelete = Event(unix.IN_DELETE) |
| 38 |
InDeleteSelf = Event(unix.IN_DELETE_SELF) |
| 39 |
InMoveSelf = Event(unix.IN_MOVE_SELF) |
| 40 |
) |
| 41 |
|
| 42 |
var osestr = map[Event]string{ |
| 43 |
InAccess: "notify.InAccess", |
| 44 |
InModify: "notify.InModify", |
| 45 |
InAttrib: "notify.InAttrib", |
| 46 |
InCloseWrite: "notify.InCloseWrite", |
| 47 |
InCloseNowrite: "notify.InCloseNowrite", |
| 48 |
InOpen: "notify.InOpen", |
| 49 |
InMovedFrom: "notify.InMovedFrom", |
| 50 |
InMovedTo: "notify.InMovedTo", |
| 51 |
InCreate: "notify.InCreate", |
| 52 |
InDelete: "notify.InDelete", |
| 53 |
InDeleteSelf: "notify.InDeleteSelf", |
| 54 |
InMoveSelf: "notify.InMoveSelf", |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
const ( |
| 59 |
inDontFollow = Event(unix.IN_DONT_FOLLOW) |
| 60 |
inExclUnlink = Event(unix.IN_EXCL_UNLINK) |
| 61 |
inMaskAdd = Event(unix.IN_MASK_ADD) |
| 62 |
inOneshot = Event(unix.IN_ONESHOT) |
| 63 |
inOnlydir = Event(unix.IN_ONLYDIR) |
| 64 |
) |
| 65 |
|
| 66 |
type event struct { |
| 67 |
sys unix.InotifyEvent |
| 68 |
path string |
| 69 |
event Event |
| 70 |
} |
| 71 |
|
| 72 |
func (e *event) Event() Event { return e.event } |
| 73 |
func (e *event) Path() string { return e.path } |
| 74 |
func (e *event) Sys() interface{} { return &e.sys } |
| 75 |
func (e *event) isDir() (bool, error) { return e.sys.Mask&unix.IN_ISDIR != 0, nil } |