I have a FSEvents
stream, I observe a folder. When I add some files to that folder, callback function triggers that. But, I thought that I can check a specific event with FSEventStreamEventFlags
constants, like add file to my folder, or check that the file was modified, but I can't. I could make this only with history done:
void fileSystemEventCallback(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) {
char **paths = eventPaths;
int i;
for (i = 0; i < numEvents; i++) {
if (eventFlags[i]==kFSEventStreamEventFlagHistoryDone) {
NSLog(@"history Done");
}
}
I check all others FSEventStreamEventFlags
constants and there is no constant that will trigger add a file to my folder or modify file or delete. I use this construction for now:
void fileSystemEventCallback(ConstFSEventStreamRef streamRef, void *clientCallBackInfo, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) {
char **paths = eventPaths;
int i;
for (i = 0; i < numEvents; i++) {
if (eventFlags[i]==kFSEventStreamEventFlagHistoryDone) {
NSLog(@"history Done");
}
else{
NSLog(@"some activity in a folder");
}
}
But when I use this construction, I get a multiple callback (i.e. I have a multiple NSLog message "some activity in a folder"), when I add file or something else. Why? How can I make to get only one callback?