From ee190d07c58c3d6d7a08df6e7f05405aa797ab44 Mon Sep 17 00:00:00 2001 From: Richard van Zon Date: Wed, 29 Feb 2012 13:13:31 +0100 Subject: [PATCH 1/2] Added support for directory symbolic links --- Tools/XcodeCapp/TNXCodeCapp.m | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Tools/XcodeCapp/TNXCodeCapp.m b/Tools/XcodeCapp/TNXCodeCapp.m index bb1196b01..b1b7d2dda 100644 --- a/Tools/XcodeCapp/TNXCodeCapp.m +++ b/Tools/XcodeCapp/TNXCodeCapp.m @@ -125,8 +125,8 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification return; [self stopEventStream]; - - NSArray *pathsToWatch = [NSArray arrayWithObject:aPath]; + + NSMutableArray *pathsToWatch = [NSMutableArray arrayWithObject:aPath]; void *appPointer = (void *)self; FSEventStreamContext context = {0, appPointer, NULL, NULL, NULL}; CFTimeInterval latency = 2.0; @@ -143,6 +143,26 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification flags = kFSEventStreamCreateFlagUseCFTypes; } + // add symlinked directories + NSFileManager *fileManager = [NSFileManager defaultManager]; + NSError *error; + + NSArray *fileList = [fileManager contentsOfDirectoryAtPath:aPath error:&error]; + + for (NSString *node in fileList) + { + NSDictionary *attributes = [fileManager attributesOfItemAtPath:aPath error:&error]; + if ([[attributes objectForKey:@"NSFileType"] isEqualTo:NSFileTypeDirectory]) + { + NSString *subDirectoryPath = [aPath stringByAppendingPathComponent:node]; + NSString *symlinkDestination = [fileManager destinationOfSymbolicLinkAtPath:subDirectoryPath error:&error]; + if (symlinkDestination) + { + [pathsToWatch addObject:subDirectoryPath]; + } + } + } + stream = FSEventStreamCreate(NULL, &fsevents_callback, &context, (CFArrayRef) pathsToWatch, [lastEventId unsignedLongLongValue], latency, flags); From d56a15db83ce83c825e3645bcba6727dd086b441 Mon Sep 17 00:00:00 2001 From: Richard van Zon Date: Mon, 9 Apr 2012 08:06:53 +0200 Subject: [PATCH 2/2] Using fm instance and ignore errors --- Tools/XcodeCapp/TNXCodeCapp.m | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Tools/XcodeCapp/TNXCodeCapp.m b/Tools/XcodeCapp/TNXCodeCapp.m index b1b7d2dda..43faf874e 100644 --- a/Tools/XcodeCapp/TNXCodeCapp.m +++ b/Tools/XcodeCapp/TNXCodeCapp.m @@ -144,18 +144,15 @@ NSString * const XCCListeningStartNotification = @"XCCListeningStartNotification } // add symlinked directories - NSFileManager *fileManager = [NSFileManager defaultManager]; - NSError *error; - - NSArray *fileList = [fileManager contentsOfDirectoryAtPath:aPath error:&error]; + NSArray *fileList = [fm contentsOfDirectoryAtPath:aPath error:nil]; for (NSString *node in fileList) { - NSDictionary *attributes = [fileManager attributesOfItemAtPath:aPath error:&error]; + NSDictionary *attributes = [fm attributesOfItemAtPath:aPath error:nil]; if ([[attributes objectForKey:@"NSFileType"] isEqualTo:NSFileTypeDirectory]) { NSString *subDirectoryPath = [aPath stringByAppendingPathComponent:node]; - NSString *symlinkDestination = [fileManager destinationOfSymbolicLinkAtPath:subDirectoryPath error:&error]; + NSString *symlinkDestination = [fm destinationOfSymbolicLinkAtPath:subDirectoryPath error:nil]; if (symlinkDestination) { [pathsToWatch addObject:subDirectoryPath];