Changeset 651
- Timestamp:
- 08/02/08 17:31:23 (4 months ago)
- Files:
-
- branches/CoreData/SapphireFrappliance/MetaData/SapphireMObjects/SapphireDirectoryMetaData.m (modified) (2 diffs)
- branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataScanner.h (modified) (1 diff)
- branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataScanner.m (modified) (5 diffs)
- branches/CoreData/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj (modified) (12 diffs)
- branches/CoreData/SapphireFrappliance/main_debug.m (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/CoreData/SapphireFrappliance/MetaData/SapphireMObjects/SapphireDirectoryMetaData.m
r650 r651 405 405 406 406 if(modified) 407 { 407 408 [self clearPredicateCache]; 408 [SapphireMetaDataSupport save:moc]; 409 [SapphireMetaDataSupport save:moc]; 410 } 409 411 } 410 412 … … 571 573 SapphireMetaDataScanner *scanner = [[SapphireMetaDataScanner alloc] initWithDirectoryMetaData:self delegate:subDelegate]; 572 574 573 NSPredicate *fetchPredicate = [NSPredicate predicateWithFormat:@"pa rent = %@", self];575 NSPredicate *fetchPredicate = [NSPredicate predicateWithFormat:@"path BEGINSWITH %@", [self.path stringByAppendingString:@"/"]]; 574 576 NSSortDescriptor *sort = [[NSSortDescriptor alloc] initWithKey:@"path" ascending:YES]; 575 577 NSManagedObjectContext *moc = [self managedObjectContext]; 576 578 NSArray *dirs = doSortedFetchRequest(SapphireDirectoryMetaDataName, moc, fetchPredicate, sort); 577 579 NSArray *files = doSortedFetchRequest(SapphireFileMetaDataName, moc, fetchPredicate, sort); 578 fetchPredicate = [NSPredicate predicateWithFormat:@"containingDirectory = %@", self];579 580 NSArray *symDirs = doSortedFetchRequest(SapphireDirectorySymLinkName, moc, fetchPredicate, sort); 580 581 NSArray *symFiles = doSortedFetchRequest(SapphireFileSymLinkName, moc, fetchPredicate, sort); branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataScanner.h
r650 r651 40 40 NSMutableArray *symDirs; /*!< @brief The list of symbolic linked dirs in this directory*/ 41 41 NSMutableArray *symFiles; /*!< @brief The list of symbolic linked files in this directory*/ 42 NSMutableArray *dirsComp; /*!< @brief The list of dirs in this directory in path components*/ 43 NSMutableArray *filesComp; /*!< @brief The list of files in this directory in path components*/ 44 NSMutableArray *symDirsComp; /*!< @brief The list of symbolic linked dirs in this directory in path components*/ 45 NSMutableArray *symFilesComp; /*!< @brief The list of symbolic linked files in this directory in path components*/ 46 47 NSMutableDictionary *subScanners; /*!< @brief The sub-scanners of this scanner*/ 42 48 int depth; /*!< @brief The directory depth of this scanner*/ 43 49 } branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataScanner.m
r650 r651 35 35 delegate = [newDelegate retain]; 36 36 dirs = files = symDirs = symFiles = nil; 37 dirsComp = filesComp = symDirsComp = symFilesComp = nil; 38 subScanners = [[NSMutableDictionary alloc] init]; 39 depth = [[[meta path] pathComponents] count]; 37 40 } 38 41 return self; … … 50 53 [symDirs release]; 51 54 [symFiles release]; 55 [subScanners release]; 56 [dirsComp release]; 57 [filesComp release]; 58 [symDirsComp release]; 59 [symFilesComp release]; 52 60 [super dealloc]; 53 61 } … … 70 78 } 71 79 72 - (void)setSubDirs:(NSArray *)subDirs files:(NSArray *)subFiles symDirs:(NSArray *)subSymDirs symFiles:(NSArray *)subSymFiles80 - (void)setSubDirs:(NSArray *)subDirs components:(NSArray *)components 73 81 { 74 82 dirs = [subDirs mutableCopy]; 83 dirsComp = [components mutableCopy]; 84 } 85 86 - (void)setSubFiles:(NSArray *)subFiles components:(NSArray *)components 87 { 75 88 files = [subFiles mutableCopy]; 89 filesComp = [components mutableCopy]; 90 } 91 92 - (void)setSubSymDirs:(NSArray *)subSymDirs components:(NSArray *)components 93 { 76 94 symDirs = [subSymDirs mutableCopy]; 95 symDirsComp = [components mutableCopy]; 96 } 97 98 - (void)setSubSymFiles:(NSArray *)subSymFiles components:(NSArray *)components 99 { 77 100 symFiles = [subSymFiles mutableCopy]; 101 symFilesComp = [components mutableCopy]; 102 } 103 104 typedef void (*subLoopCallback)(SapphireMetaDataScanner *scan, NSString *lastName, NSArray *compArray, NSArray *objArray, int startIndex, int endIndex, int newDepth); 105 106 static void subLoop(SapphireMetaDataScanner *scan, NSArray *compArray, NSArray *objArray, int currentDepth, subLoopCallback callback) 107 { 108 int i, lastStart = 0; 109 int endIndex = [objArray count]; 110 NSString *current = nil; 111 int newDepth = currentDepth + 1; 112 for(i=0; i<=endIndex; i++) 113 { 114 NSArray *components; 115 NSString *subDirName; 116 if(i == endIndex) 117 { 118 if(i == 0) 119 return; 120 components = [compArray objectAtIndex:endIndex-1]; 121 } 122 else 123 { 124 components = [compArray objectAtIndex:i]; 125 subDirName = [components objectAtIndex:currentDepth]; 126 if([current isEqualToString:subDirName]) 127 continue; 128 } 129 130 if(i != lastStart) 131 { 132 callback(scan, current, compArray, objArray, lastStart, i, newDepth); 133 lastStart = i; 134 } 135 current = subDirName; 136 } 137 } 138 139 static void subDirCallback(SapphireMetaDataScanner *scan, NSString *lastName, NSArray *compArray, NSArray *objArray, int startIndex, int endIndex, int newDepth) 140 { 141 SapphireDirectoryMetaData *subDir = [objArray objectAtIndex:startIndex]; 142 143 /* The / character isn't always first in sorted order, so make sure this isn't a case of: 144 * dirName 145 * dirName With More info 146 * dirName/subDirName 147 */ 148 SapphireMetaDataScanner *sub = [scan->subScanners objectForKey:lastName]; 149 BOOL created = NO; 150 if(sub == nil) 151 { 152 sub = [[SapphireMetaDataScanner alloc] initWithDirectoryMetaData:subDir delegate:scan]; 153 startIndex++; 154 created = YES; 155 } 156 if(startIndex != endIndex) 157 { 158 NSRange range = NSMakeRange(startIndex, endIndex-startIndex); 159 [sub setSubDirs:[objArray subarrayWithRange:range] components:[compArray subarrayWithRange:range]]; 160 } 161 if(created) 162 { 163 [scan->dirs addObject:subDir]; 164 [scan->subScanners setObject:sub forKey:lastName]; 165 [sub release]; 166 } 167 } 168 169 static void subFileCallback(SapphireMetaDataScanner *scan, NSString *lastName, NSArray *compArray, NSArray *objArray, int startIndex, int endIndex, int newDepth) 170 { 171 SapphireMetaDataScanner *sub = [scan->subScanners objectForKey:lastName]; 172 if(sub == nil) 173 { 174 if([[compArray objectAtIndex:startIndex] count] == newDepth) 175 //This was really a file 176 [scan->files addObject:[objArray objectAtIndex:startIndex]]; 177 return; 178 } 179 if(startIndex != endIndex) 180 { 181 NSRange range = NSMakeRange(startIndex, endIndex-startIndex); 182 [sub setSubFiles:[objArray subarrayWithRange:range] components:[compArray subarrayWithRange:range]]; 183 } 184 } 185 186 static void subSymDirCallback(SapphireMetaDataScanner *scan, NSString *lastName, NSArray *compArray, NSArray *objArray, int startIndex, int endIndex, int newDepth) 187 { 188 SapphireMetaDataScanner *sub = [scan->subScanners objectForKey:lastName]; 189 if(sub == nil) 190 { 191 if([[compArray objectAtIndex:startIndex] count] == newDepth) 192 //This was really a file 193 [scan->symDirs addObject:[objArray objectAtIndex:startIndex]]; 194 return; 195 } 196 if(startIndex != endIndex) 197 { 198 NSRange range = NSMakeRange(startIndex, endIndex-startIndex); 199 [sub setSubSymDirs:[objArray subarrayWithRange:range] components:[compArray subarrayWithRange:range]]; 200 } 201 } 202 203 static void subSymFileCallback(SapphireMetaDataScanner *scan, NSString *lastName, NSArray *compArray, NSArray *objArray, int startIndex, int endIndex, int newDepth) 204 { 205 SapphireMetaDataScanner *sub = [scan->subScanners objectForKey:lastName]; 206 if(sub == nil) 207 { 208 if([[compArray objectAtIndex:startIndex] count] == newDepth) 209 //This was really a file 210 [scan->symFiles addObject:[objArray objectAtIndex:startIndex]]; 211 return; 212 } 213 if(startIndex != endIndex) 214 { 215 NSRange range = NSMakeRange(startIndex, endIndex-startIndex); 216 [sub setSubSymFiles:[objArray subarrayWithRange:range] components:[compArray subarrayWithRange:range]]; 217 } 218 } 219 220 - (void)separateSubDirFiles 221 { 222 NSArray *subArray = dirs; 223 dirs = [[NSMutableArray alloc] init]; 224 subLoop(self, dirsComp, subArray, depth, subDirCallback); 225 [subArray release]; 226 227 subArray = files; 228 files = [[NSMutableArray alloc] init]; 229 subLoop(self, filesComp, subArray, depth, subFileCallback); 230 [subArray release]; 231 232 subArray = symDirs; 233 symDirs = [[NSMutableArray alloc] init]; 234 subLoop(self, symDirsComp, subArray, depth, subSymDirCallback); 235 [subArray release]; 236 237 subArray = symFiles; 238 symFiles = [[NSMutableArray alloc] init]; 239 subLoop(self, symFilesComp, subArray, depth, subSymFileCallback); 240 [subArray release]; 241 78 242 [metaDir rescanDirWithExistingDirs:dirs files:files symDirs:symDirs symFiles:symFiles]; 79 243 remaining = [dirs mutableCopy]; 80 244 [remaining addObjectsFromArray:[symDirs valueForKey:@"directory"]]; 245 } 246 247 - (void)setSubDirs:(NSArray *)subDirs files:(NSArray *)subFiles symDirs:(NSArray *)subSymDirs symFiles:(NSArray *)subSymFiles 248 { 249 NSString *pathKey = @"path.pathComponents"; 250 dirs = [subDirs mutableCopy]; 251 dirsComp = [[subDirs valueForKeyPath:pathKey] mutableCopy]; 252 files = [subFiles mutableCopy]; 253 filesComp = [[subFiles valueForKeyPath:pathKey] mutableCopy]; 254 symDirs = [subSymDirs mutableCopy]; 255 symDirsComp = [[subSymDirs valueForKeyPath:pathKey] mutableCopy]; 256 symFiles = [subSymFiles mutableCopy]; 257 symFilesComp = [[subSymFiles valueForKeyPath:pathKey] mutableCopy]; 258 [self separateSubDirFiles]; 81 259 } 82 260 … … 103 281 /*Send results*/ 104 282 [delegate gotSubFiles:results]; 283 [delegate release]; 284 delegate = nil; 105 285 [self autorelease]; 106 286 } … … 155 335 /*Scan the next directory*/ 156 336 SapphireDirectoryMetaData *next = [remaining objectAtIndex:0]; 157 /*State whether we care for results*/ 158 if(results != nil) 159 [next getSubFileMetasWithDelegate:self skipDirectories:skipDirectories]; 337 SapphireMetaDataScanner *scan = nil; 338 if([next parent] == metaDir) 339 scan = [subScanners objectForKey:[[next path] lastPathComponent]]; 340 if(scan) 341 { 342 [skipDirectories addObject:[next path]]; 343 [scan separateSubDirFiles]; 344 [scan setSkipDirectories:skipDirectories]; 345 [scan setGivesResults:results != nil]; 346 } 160 347 else 161 [next scanForNewFilesWithDelegate:self skipDirectories:skipDirectories]; 348 { 349 /*State whether we care for results*/ 350 if(results != nil) 351 [next getSubFileMetasWithDelegate:self skipDirectories:skipDirectories]; 352 else 353 [next scanForNewFilesWithDelegate:self skipDirectories:skipDirectories]; 354 } 162 355 /*remove this item*/ 163 356 [remaining removeObjectAtIndex:0]; branches/CoreData/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj
r599 r651 66 66 F5294AAD0DECB4D7004F8F4F /* SapphireMovieDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = F5294AAC0DECB4D7004F8F4F /* SapphireMovieDirectory.m */; }; 67 67 F531A98F0C2DACBE00E46F62 /* SapphireApplianceController.m in Sources */ = {isa = PBXBuildFile; fileRef = F531A98E0C2DACBE00E46F62 /* SapphireApplianceController.m */; }; 68 F532EC460E44FBB600DBEE13 /* main_debug.m in Sources */ = {isa = PBXBuildFile; fileRef = F532EC3B0E44FB8100DBEE13 /* main_debug.m */; }; 69 F532EC4A0E44FBFB00DBEE13 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F535C7420DF2353900716DA9 /* CoreData.framework */; }; 68 70 F53420560DC2F17F00498822 /* SapphireVideoPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = F53420550DC2F17F00498822 /* SapphireVideoPlayerController.m */; }; 69 71 F535C7430DF2353900716DA9 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F535C7420DF2353900716DA9 /* CoreData.framework */; }; … … 200 202 remoteInfo = "Complete Sapphire"; 201 203 }; 204 F532EC470E44FBC900DBEE13 /* PBXContainerItemProxy */ = { 205 isa = PBXContainerItemProxy; 206 containerPortal = 089C1669FE841209C02AAC07 /* Project object */; 207 proxyType = 1; 208 remoteGlobalIDString = F5B4186D0D0B29D800BDD361 /* Complete Sapphire */; 209 remoteInfo = "Complete Sapphire"; 210 }; 202 211 F56895E00D6CE30D00F9D9B0 /* PBXContainerItemProxy */ = { 203 212 isa = PBXContainerItemProxy; … … 336 345 F531A98D0C2DACBE00E46F62 /* SapphireApplianceController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SapphireApplianceController.h; sourceTree = "<group>"; }; 337 346 F531A98E0C2DACBE00E46F62 /* SapphireApplianceController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SapphireApplianceController.m; sourceTree = "<group>"; }; 347 F532EC3B0E44FB8100DBEE13 /* main_debug.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main_debug.m; sourceTree = "<group>"; }; 348 F532EC420E44FBAB00DBEE13 /* Debug_test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Debug_test; sourceTree = BUILT_PRODUCTS_DIR; }; 338 349 F53420540DC2F17F00498822 /* SapphireVideoPlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SapphireVideoPlayerController.h; sourceTree = "<group>"; }; 339 350 F53420550DC2F17F00498822 /* SapphireVideoPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SapphireVideoPlayerController.m; sourceTree = "<group>"; }; … … 558 569 runOnlyForDeploymentPostprocessing = 0; 559 570 }; 571 F532EC400E44FBAB00DBEE13 /* Frameworks */ = { 572 isa = PBXFrameworksBuildPhase; 573 buildActionMask = 2147483647; 574 files = ( 575 F532EC4A0E44FBFB00DBEE13 /* CoreData.framework in Frameworks */, 576 ); 577 runOnlyForDeploymentPostprocessing = 0; 578 }; 560 579 F5B4185D0D0B288700BDD361 /* Frameworks */ = { 561 580 isa = PBXFrameworksBuildPhase; … … 577 596 19C28FB8FE9D52D311CA2CBB /* Products */, 578 597 F51BFD2D0D26BDF300E22363 /* SapphireCompatibilityClasses.xcodeproj */, 598 F532EC3B0E44FB8100DBEE13 /* main_debug.m */, 579 599 ); 580 600 name = ApplianceBase; … … 652 672 F5B4185F0D0B288700BDD361 /* ImportHelper */, 653 673 F5003FF90D19980B003FEA08 /* LeopardOnly.framework */, 674 F532EC420E44FBAB00DBEE13 /* Debug_test */, 654 675 ); 655 676 name = Products; … … 987 1008 productType = "com.apple.product-type.framework"; 988 1009 }; 1010 F532EC410E44FBAB00DBEE13 /* Debug_test */ = { 1011 isa = PBXNativeTarget; 1012 buildConfigurationList = F532EC640E44FC1900DBEE13 /* Build configuration list for PBXNativeTarget "Debug_test" */; 1013 buildPhases = ( 1014 F532EC3F0E44FBAB00DBEE13 /* Sources */, 1015 F532EC400E44FBAB00DBEE13 /* Frameworks */, 1016 ); 1017 buildRules = ( 1018 ); 1019 dependencies = ( 1020 F532EC480E44FBC900DBEE13 /* PBXTargetDependency */, 1021 ); 1022 name = Debug_test; 1023 productName = Debug_test; 1024 productReference = F532EC420E44FBAB00DBEE13 /* Debug_test */; 1025 productType = "com.apple.product-type.tool"; 1026 }; 989 1027 F5B4185E0D0B288700BDD361 /* ImportHelper */ = { 990 1028 isa = PBXNativeTarget; … … 1028 1066 F5B4185E0D0B288700BDD361 /* ImportHelper */, 1029 1067 F5003FF80D19980A003FEA08 /* LeopardOnly */, 1068 F532EC410E44FBAB00DBEE13 /* Debug_test */, 1030 1069 ); 1031 1070 }; … … 1236 1275 runOnlyForDeploymentPostprocessing = 0; 1237 1276 }; 1277 F532EC3F0E44FBAB00DBEE13 /* Sources */ = { 1278 isa = PBXSourcesBuildPhase; 1279 buildActionMask = 2147483647; 1280 files = ( 1281 F532EC460E44FBB600DBEE13 /* main_debug.m in Sources */, 1282 ); 1283 runOnlyForDeploymentPostprocessing = 0; 1284 }; 1238 1285 F5B4185C0D0B288700BDD361 /* Sources */ = { 1239 1286 isa = PBXSourcesBuildPhase; … … 1256 1303 target = F5B4186D0D0B29D800BDD361 /* Complete Sapphire */; 1257 1304 targetProxy = F5038FA60DE7AB600046C674 /* PBXContainerItemProxy */; 1305 }; 1306 F532EC480E44FBC900DBEE13 /* PBXTargetDependency */ = { 1307 isa = PBXTargetDependency; 1308 target = F5B4186D0D0B29D800BDD361 /* Complete Sapphire */; 1309 targetProxy = F532EC470E44FBC900DBEE13 /* PBXContainerItemProxy */; 1258 1310 }; 1259 1311 F585A9C70D74EA810043AB22 /* PBXTargetDependency */ = { … … 1459 1511 name = Release; 1460 1512 }; 1513 F532EC440E44FBAC00DBEE13 /* Debug */ = { 1514 isa = XCBuildConfiguration; 1515 buildSettings = { 1516 ALWAYS_SEARCH_USER_PATHS = NO; 1517 COPY_PHASE_STRIP = NO; 1518 GCC_DYNAMIC_NO_PIC = NO; 1519 GCC_ENABLE_FIX_AND_CONTINUE = YES; 1520 GCC_MODEL_TUNING = G5; 1521 GCC_OPTIMIZATION_LEVEL = 0; 1522 GCC_PRECOMPILE_PREFIX_HEADER = YES; 1523 GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h"; 1524 INSTALL_PATH = /usr/local/bin; 1525 OTHER_LDFLAGS = ( 1526 "-undefined", 1527 dynamic_lookup, 1528 ); 1529 PREBINDING = NO; 1530 PRODUCT_NAME = Debug_test; 1531 }; 1532 name = Debug; 1533 }; 1534 F532EC450E44FBAC00DBEE13 /* Release */ = { 1535 isa = XCBuildConfiguration; 1536 buildSettings = { 1537 ALWAYS_SEARCH_USER_PATHS = NO; 1538 COPY_PHASE_STRIP = YES; 1539 DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 1540 GCC_ENABLE_FIX_AND_CONTINUE = NO; 1541 GCC_MODEL_TUNING = G5; 1542 GCC_PRECOMPILE_PREFIX_HEADER = YES; 1543 GCC_PREFIX_HEADER = "$(SYSTEM_LIBRARY_DIR)/Frameworks/AppKit.framework/Headers/AppKit.h"; 1544 INSTALL_PATH = /usr/local/bin; 1545 OTHER_LDFLAGS = ( 1546 "-framework", 1547 Foundation, 1548 "-framework", 1549 AppKit, 1550 ); 1551 PREBINDING = NO; 1552 PRODUCT_NAME = Debug_test; 1553 ZERO_LINK = NO; 1554 }; 1555 name = Release; 1556 }; 1461 1557 F5B418610D0B288800BDD361 /* Debug */ = { 1462 1558 isa = XCBuildConfiguration; … … 1579 1675 defaultConfigurationName = Release; 1580 1676 }; 1677 F532EC640E44FC1900DBEE13 /* Build configuration list for PBXNativeTarget "Debug_test" */ = { 1678 isa = XCConfigurationList; 1679 buildConfigurations = ( 1680 F532EC440E44FBAC00DBEE13 /* Debug */, 1681 F532EC450E44FBAC00DBEE13 /* Release */, 1682 ); 1683 defaultConfigurationIsVisible = 0; 1684 defaultConfigurationName = Release; 1685 }; 1581 1686 F5B418660D0B28A200BDD361 /* Build configuration list for PBXNativeTarget "ImportHelper" */ = { 1582 1687 isa = XCConfigurationList;
