i'm having trouble with the macOS framework FSEvents: when i call FSEventStreamCreate
and pass kFSEventStreamEventIdSinceNow
for the "since" argument, i still receive kFSEventStreamEventFlagItemCreated
events for files that have already been generated a few seconds before the stream has been created and scheduled.
NSArray* paths = createDummyFilesOnFileSystem();
sleepForFiveSeconds();
CFRunLoopRef runLoop = ...;
FSEventStreamContext context = ...;
CFTimeInterval latency = 0.5;
FSEventStreamCreateFlags streamCreateFlags =
kFSEventStreamCreateFlagUseCFTypes |
kFSEventStreamCreateFlagNoDefer |
kFSEventStreamCreateFlagWatchRoot |
kFSEventStreamCreateFlagFileEvents;
FSEventStreamRef stream = FSEventStreamCreate(NULL,
&fsEventCallback,
&context,
(__bridge CFArrayRef) paths,
kFSEventStreamEventIdSinceNow,
latency,
streamCreateFlags);
FSEventStreamScheduleWithRunLoop(stream, runLoop, kCFRunLoopDefaultMode);
FSEventStreamStart(stream);
Is there anything i can do to avoid receiving kFSEventStreamEventFlagItemCreated
notifications for those files created earlier, or any way i can filter those out ( e.g. by looking at other flags)? I've already tried flushing the stream initially and passing FSEventsGetCurrentEventId()
for the since parameter, but that did not help either.
Thanks!