From 7ae519145f7f2deda2facb83ba9539044547f2c8 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Mon, 7 Nov 2011 22:03:48 +0100 Subject: [PATCH] some processing optimizations --- Tools/XcodeCapp/FSEventCallback.m | 46 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/Tools/XcodeCapp/FSEventCallback.m b/Tools/XcodeCapp/FSEventCallback.m index 54875fc10..8c90cdf3a 100644 --- a/Tools/XcodeCapp/FSEventCallback.m +++ b/Tools/XcodeCapp/FSEventCallback.m @@ -40,19 +40,15 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, [xcc updateLastEventId:eventIds[i]]; NSString *path = [[(NSArray *)eventPaths objectAtIndex:i] stringByStandardizingPath]; - BOOL isDir = NO; - - [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir]; if (useFileBasedListening) { - BOOL hasBeenProcessed = NO; // kFSEventStreamEventFlagItemIsFile = 0x00010000 // kFSEventStreamEventFlagItemRemoved = 0x00000200 if (eventFlags[i] & 0x00010000 && eventFlags[i] & 0x00000200) { [xcc tidyShadowedFiles:path]; - hasBeenProcessed = YES; + continue; } // kFSEventStreamEventFlagItemIsFile = 0x00010000 @@ -62,32 +58,42 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, continue; // kFSEventStreamEventFlagItemRemoved = 0x00000200 - if (eventFlags[i] & 0x00000200) + else if (eventFlags[i] & 0x00000200) { DLog(@"event type: kFSEventStreamEventFlagItemRemoved for path %@", path); [xcc handleFileRemoval:path]; - hasBeenProcessed = YES; } // kFSEventStreamEventFlagItemCreated = 0x00000200 // kFSEventStreamEventFlagItemModified = 0x00001000 - if (eventFlags[i] & 0x00000100 || eventFlags[i] & 0x00001000) + else if (eventFlags[i] & 0x00000100 || eventFlags[i] & 0x00001000) { DLog(@"event type: kFSEventStreamEventFlagItemCreated or kFSEventStreamEventFlagItemModified for path %@", path); [xcc handleFileModification:path notify:YES]; - hasBeenProcessed = YES; + } + + // kFSEventStreamEventFlagItemFinderInfoMod = 0x00002000 + // kFSEventStreamEventFlagItemChangeOwner = 0x00004000 + // kFSEventStreamEventFlagItemXattrMod = 0x00008000 + else if ([xcc reactToInodeModification] && + (eventFlags[i] & 0x00004000 + || eventFlags[i] & 0x00002000 + || eventFlags[i] & 0x00008000)) + { + DLog(@"event type: kFSEventStreamEventFlagItemChangeOwner for path %@", path); + [xcc handleFileModification:path notify:YES]; } // kFSEventStreamEventFlagItemInodeMetaMod = 0x00000400 - if ([xcc reactToInodeModification] && eventFlags[i] & 0x00000400) + else if ([xcc reactToInodeModification] && + (eventFlags[i] & 0x00000400)) { DLog(@"event type: kFSEventStreamEventFlagItemInodeMetaMod for path %@", path); [xcc handleFileModification:path notify:YES]; - hasBeenProcessed = YES; } // kFSEventStreamEventFlagItemRenamed = 0x00000800 - if (eventFlags[i] & 0x00000800) + else if (eventFlags[i] & 0x00000800) { if (![[NSFileManager defaultManager] fileExistsAtPath:path]) { @@ -99,25 +105,19 @@ void fsevents_callback(ConstFSEventStreamRef streamRef, DLog(@"event type: kFSEventStreamEventFlagItemRenamed for path %@ (added destination)", path); [xcc handleFileModification:path notify:YES]; } - hasBeenProcessed = YES; - } - - // Well it seems to be an unknown event, let's just process it. - if (!hasBeenProcessed) - { - DLog(@"event type: Unknown for path %@ (no big deal, we process it)", path); - [xcc handleFileModification:path notify:YES]; } } else { - NSArray *subpaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL]; - // If for some reasons the path is not a directory, - // we don't want to deal with it in this mode. + // we don't want to deal with it in this mode. + BOOL isDir = NO; + [[NSFileManager defaultManager] fileExistsAtPath:path isDirectory:&isDir]; if (!isDir) continue; + NSArray *subpaths = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:NULL]; + [xcc tidyShadowedFiles:path]; for (NSString *subpath in subpaths)