Revision: 2772 http://skim-app.svn.sourceforge.net/skim-app/?rev=2772&view=rev Author: hofman Date: 2007-08-29 09:23:04 -0700 (Wed, 29 Aug 2007)
Log Message: ----------- First look at standard locations when reading a PDF bundle. Modified Paths: -------------- trunk/SKDocument.m Modified: trunk/SKDocument.m =================================================================== --- trunk/SKDocument.m 2007-08-29 15:27:36 UTC (rev 2771) +++ trunk/SKDocument.m 2007-08-29 16:23:04 UTC (rev 2772) @@ -521,24 +521,29 @@ } else if ([docType isEqualToString:SKPDFBundleDocumentType]) { NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] initWithPath:[absoluteURL path]]; NSDictionary *fileWrappers = [fileWrapper fileWrappers]; - NSData *notesData = nil; - NSEnumerator *nameEnum = [fileWrappers keyEnumerator]; - NSString *name; + NSArray *noteArray = nil; + NSFileWrapper *fw; - while (name = [nameEnum nextObject]) { - NSFileWrapper *fw = [fileWrappers objectForKey:name]; - if ([fw isRegularFile] == NO) - continue; - NSString *extension = [[fw filename] pathExtension]; - if ([name caseInsensitiveCompare:WRAPPER_PDF_FILENAME] == NSOrderedSame || (data == nil && [extension caseInsensitiveCompare:@"pdf"] == NSOrderedSame)) { - if (data = [[fw regularFileContents] retain]) - pdfDoc = [[PDFDocument alloc] initWithData:data]; - } else if ([name caseInsensitiveCompare:WRAPPER_SKIM_FILENAME] == NSOrderedSame || (notesData == nil && [extension caseInsensitiveCompare:@"skim"] == NSOrderedSame)) { - notesData = [fw regularFileContents]; - NSArray *array = [NSKeyedUnarchiver unarchiveObjectWithData:notesData]; - if (array) - [self setNoteDicts:array]; + if ((fw = [fileWrappers objectForKey:WRAPPER_PDF_FILENAME]) && [fw isRegularFile]) + data = [[fw regularFileContents] retain]; + if ((fw = [fileWrappers objectForKey:WRAPPER_SKIM_FILENAME]) && [fw isRegularFile] && + (noteArray = [NSKeyedUnarchiver unarchiveObjectWithData:[fw regularFileContents]])) + [self setNoteDicts:noteArray]; + if (data == nil || noteArray == nil) { + NSArray *fws = [fileWrappers allValues]; + NSArray *extensions = [fws valueForKeyPath:@"filename.pathExtension.lowercaseString"]; + unsigned int index; + if (data == nil) { + index = [extensions indexOfObject:@"pdf"]; + if ((index != NSNotFound) && (fw = [fws objectAtIndex:index]) && [fw isRegularFile]) + data = [[fw regularFileContents] retain]; } + if (noteArray == nil) { + index = [extensions indexOfObject:@"skim"]; + if ((index != NSNotFound) && (fw = [fws objectAtIndex:index]) && [fw isRegularFile] && + (noteArray = [NSKeyedUnarchiver unarchiveObjectWithData:[fw regularFileContents]])) + [self setNoteDicts:noteArray]; + } } [fileWrapper release]; } else if ([docType isEqualToString:SKPostScriptDocumentType]) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit