6

According to Apple documentation, in the callback to FSEvents,

/* These flags are only set if you specified the FileEvents */
/*   flags when creating the stream. */
kFSEventStreamEventFlagItemCreated = 0x00000100, 
kFSEventStreamEventFlagItemRemoved = 0x00000200, 
kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400, 
kFSEventStreamEventFlagItemRenamed = 0x00000800, 
kFSEventStreamEventFlagItemModified = 0x00001000, 
kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000, 
kFSEventStreamEventFlagItemChangeOwner = 0x00004000, 
kFSEventStreamEventFlagItemXattrMod = 0x00008000, 
kFSEventStreamEventFlagItemIsFile = 0x00010000, 
kFSEventStreamEventFlagItemIsDir = 0x00020000, 
kFSEventStreamEventFlagItemIsSymlink = 0x00040000 

However, I triple checked that the kFSEventStreamCreateFlagFileEvents flag is not being set when calling

FSEventStreamRef FSEventStreamCreate( 
    CFAllocatorRef allocator, 
    FSEventStreamCallback callback, 
    FSEventStreamContext *context, 
    CFArrayRef pathsToWatch, 
    FSEventStreamEventId sinceWhen, 
    CFTimeInterval latency, 
    FSEventStreamCreateFlags flags);  

But no matter what I do, the kFSEventStreamEventFlagItem* flags are still being set when the events are passed to me from the FSEvents API. I suspect this is a bug, but I'm not quite sure. I'm using OS X Lion 10.7.2

Sample code can be found here. http://stuconnolly.com/downloads/scevents/

EDIT

The question is:
Has anyone else experienced the same results?
Is this a behavior I can rely on to check for the file event flags?

Bohemian
  • 412,405
  • 93
  • 575
  • 722
Tony
  • 36,591
  • 10
  • 48
  • 83
  • oops, added the question. thanks for pointing out – Tony Feb 05 '12 at 05:04
  • Seeing the same thing. OS 10.8.2 here. It definitely isn't behaving the way the documentation suggests. – John Bowers Nov 27 '12 at 19:24
  • In my case, I am testing for both `kFSEventStreamEventFlagItemCreated` and `kFSEventStreamEventFlagItemIsFile`. When I create a new file in the watched directory, the callback is called but these flags aren't set!! – Nicolas Miari Nov 09 '13 at 09:49

1 Answers1

0

In fact,these flags are set normally although the flag looks wrong.

For example,you got a flag 133120.That is 0x20800. So,you should notice "kFSEventStreamEventFlagItemRenamed = 0x00000800" and "kFSEventStreamEventFlagItemIsDir = 0x00020000".

That is to say, kFSEventStreamEventFlagItemRenamed & kFSEventStreamEventFlagItemIsDir are what you want.

Kakashi
  • 31
  • 6