event_fsevents.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (c) 2014-2015 The Notify Authors. All rights reserved.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. // +build darwin,!kqueue
  5. package notify
  6. const (
  7. osSpecificCreate = Event(FSEventsCreated)
  8. osSpecificRemove = Event(FSEventsRemoved)
  9. osSpecificWrite = Event(FSEventsModified)
  10. osSpecificRename = Event(FSEventsRenamed)
  11. // internal = Event(0x100000)
  12. // recursive is used to distinguish recursive eventsets from non-recursive ones
  13. recursive = Event(0x200000)
  14. // omit is used for dispatching internal events; only those events are sent
  15. // for which both the event and the watchpoint has omit in theirs event sets.
  16. omit = Event(0x400000)
  17. )
  18. // FSEvents specific event values.
  19. const (
  20. FSEventsMustScanSubDirs Event = 0x00001
  21. FSEventsUserDropped = 0x00002
  22. FSEventsKernelDropped = 0x00004
  23. FSEventsEventIdsWrapped = 0x00008
  24. FSEventsHistoryDone = 0x00010
  25. FSEventsRootChanged = 0x00020
  26. FSEventsMount = 0x00040
  27. FSEventsUnmount = 0x00080
  28. FSEventsCreated = 0x00100
  29. FSEventsRemoved = 0x00200
  30. FSEventsInodeMetaMod = 0x00400
  31. FSEventsRenamed = 0x00800
  32. FSEventsModified = 0x01000
  33. FSEventsFinderInfoMod = 0x02000
  34. FSEventsChangeOwner = 0x04000
  35. FSEventsXattrMod = 0x08000
  36. FSEventsIsFile = 0x10000
  37. FSEventsIsDir = 0x20000
  38. FSEventsIsSymlink = 0x40000
  39. )
  40. var osestr = map[Event]string{
  41. FSEventsMustScanSubDirs: "notify.FSEventsMustScanSubDirs",
  42. FSEventsUserDropped: "notify.FSEventsUserDropped",
  43. FSEventsKernelDropped: "notify.FSEventsKernelDropped",
  44. FSEventsEventIdsWrapped: "notify.FSEventsEventIdsWrapped",
  45. FSEventsHistoryDone: "notify.FSEventsHistoryDone",
  46. FSEventsRootChanged: "notify.FSEventsRootChanged",
  47. FSEventsMount: "notify.FSEventsMount",
  48. FSEventsUnmount: "notify.FSEventsUnmount",
  49. FSEventsInodeMetaMod: "notify.FSEventsInodeMetaMod",
  50. FSEventsFinderInfoMod: "notify.FSEventsFinderInfoMod",
  51. FSEventsChangeOwner: "notify.FSEventsChangeOwner",
  52. FSEventsXattrMod: "notify.FSEventsXattrMod",
  53. FSEventsIsFile: "notify.FSEventsIsFile",
  54. FSEventsIsDir: "notify.FSEventsIsDir",
  55. FSEventsIsSymlink: "notify.FSEventsIsSymlink",
  56. }
  57. type event struct {
  58. fse FSEvent
  59. event Event
  60. }
  61. func (ei *event) Event() Event { return ei.event }
  62. func (ei *event) Path() string { return ei.fse.Path }
  63. func (ei *event) Sys() interface{} { return &ei.fse }
  64. func (ei *event) isDir() (bool, error) { return ei.fse.Flags&FSEventsIsDir != 0, nil }