| | 40 | if([[path pathExtension] isEqualToString:@"mov"]) |
| | 41 | { |
| | 42 | //Find all references to see if this is a joined movie. |
| | 43 | NSError *error = nil; |
| | 44 | QTMovie *movie = [QTMovie movieWithFile:path error:&error]; |
| | 45 | NSMutableSet *filePaths = [NSMutableSet set]; |
| | 46 | NSArray *tracks = [movie tracks]; |
| | 47 | int trackCount = [tracks count]; |
| | 48 | int i; |
| | 49 | for(i=0; i<trackCount; i++) |
| | 50 | { |
| | 51 | QTTrack *track = [tracks objectAtIndex:i]; |
| | 52 | QTMedia *media = [track media]; |
| | 53 | if(media != nil) |
| | 54 | { |
| | 55 | Media qtMedia = [media quickTimeMedia]; |
| | 56 | short count; |
| | 57 | GetMediaDataRefCount(qtMedia, &count); |
| | 58 | for(int i=0; i<count; i++) |
| | 59 | { |
| | 60 | Handle dataRef; |
| | 61 | OSType dataRefType; |
| | 62 | long dataRefAttrs; |
| | 63 | if(GetMediaDataRef(qtMedia, i, &dataRef, &dataRefType, &dataRefAttrs) == noErr && dataRefType == AliasDataHandlerSubType) |
| | 64 | { |
| | 65 | CFStringRef outPath; |
| | 66 | if(QTGetDataReferenceFullPathCFString(dataRef, dataRefType, (QTPathStyle)kQTNativeDefaultPathStyle, &outPath) == noErr) |
| | 67 | { |
| | 68 | [filePaths addObject:(NSString *)outPath]; |
| | 69 | CFRelease(outPath); |
| | 70 | } |
| | 71 | DisposeHandle(dataRef); |
| | 72 | } |
| | 73 | } |
| | 74 | } |
| | 75 | } |
| | 76 | [filePaths removeObject:path]; |
| | 77 | SapphireJoinedFile *joined = [metaData joinedFile]; |
| | 78 | if([filePaths count]) |
| | 79 | { |
| | 80 | NSManagedObjectContext *moc = [metaData managedObjectContext]; |
| | 81 | //This is a joined file |
| | 82 | if(joined == nil) |
| | 83 | joined = [SapphireJoinedFile joinedFileForPath:path inContext:moc]; |
| | 84 | NSEnumerator *pathEnum = [filePaths objectEnumerator]; |
| | 85 | NSString *otherPath; |
| | 86 | while((otherPath = [pathEnum nextObject]) != nil) |
| | 87 | [joined addJoinedFilesObject:[SapphireFileMetaData createFileWithPath:otherPath inContext:moc]]; |
| | 88 | } |
| | 89 | else if(joined != nil) |
| | 90 | //This is not a joined file, so mark as such |
| | 91 | [metaData setJoinedFile:nil]; |
| | 92 | } |