Revision: 2825 http://skim-app.svn.sourceforge.net/skim-app/?rev=2825&view=rev Author: hofman Date: 2007-09-04 08:32:08 -0700 (Tue, 04 Sep 2007)
Log Message: ----------- Read PDF bundle data initially the way we write it, using the bundle's name for the content files. Modified Paths: -------------- trunk/SKDocument.m Modified: trunk/SKDocument.m =================================================================== --- trunk/SKDocument.m 2007-09-04 12:24:29 UTC (rev 2824) +++ trunk/SKDocument.m 2007-09-04 15:32:08 UTC (rev 2825) @@ -520,37 +520,49 @@ } } else if ([docType isEqualToString:SKPDFBundleDocumentType]) { NSFileWrapper *fileWrapper = [[NSFileWrapper alloc] initWithPath:[absoluteURL path]]; + NSFileWrapper *pdfFW = nil; + NSFileWrapper *skimFW = nil; NSDictionary *fileWrappers = [fileWrapper fileWrappers]; NSArray *noteArray = nil; - NSFileWrapper *fw; + NSString *name = [[[absoluteURL path] lastPathComponent] stringByDeletingPathExtension]; + if ([name caseInsensitiveCompare:BUNDLE_DATA_FILENAME] == NSOrderedSame) + name = [name stringByAppendingString:@"1"]; - if ((fw = [fileWrappers objectForKey:BUNDLE_DATA_FILENAME]) && [fw isRegularFile]) { - data = [[fw regularFileContents] retain]; - pdfDoc = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:[[absoluteURL path] stringByAppendingPathComponent:[fw filename]]]]; - } - if ((fw = [fileWrappers objectForKey:BUNDLE_DATA_FILENAME]) && [fw isRegularFile]) { - if (noteArray = [NSKeyedUnarchiver unarchiveObjectWithData:[fw regularFileContents]]) - [self setNoteDicts:noteArray]; - } - if (data == nil || noteArray == nil) { + pdfFW = [fileWrappers objectForKey:[name stringByAppendingPathExtension:@"pdf"]]; + if ([pdfFW isRegularFile] == NO) + pdfFW = nil; + skimFW = [fileWrappers objectForKey:[name stringByAppendingPathExtension:@"skim"]]; + if ([skimFW isRegularFile] == NO) + skimFW = nil; + if (pdfFW == nil || skimFW == nil) { NSArray *fws = [fileWrappers allValues]; NSArray *extensions = [fws valueForKeyPath:@"filename.pathExtension.lowercaseString"]; unsigned int index; - if (data == nil) { + if (pdfFW == nil) { index = [extensions indexOfObject:@"pdf"]; - if ((index != NSNotFound) && (fw = [fws objectAtIndex:index]) && [fw isRegularFile]) { - data = [[fw regularFileContents] retain]; - pdfDoc = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:[[absoluteURL path] stringByAppendingPathComponent:[fw filename]]]]; + if (index != NSNotFound) { + pdfFW = [fws objectAtIndex:index]; + if ([pdfFW isRegularFile] == NO) + pdfFW = nil; } } - if (noteArray == nil) { + if (skimFW == nil) { index = [extensions indexOfObject:@"skim"]; - if ((index != NSNotFound) && (fw = [fws objectAtIndex:index]) && [fw isRegularFile]) { - if (noteArray = [NSKeyedUnarchiver unarchiveObjectWithData:[fw regularFileContents]]) - [self setNoteDicts:noteArray]; + if (index != NSNotFound) { + skimFW = [fws objectAtIndex:index]; + if ([skimFW isRegularFile] == NO) + skimFW = nil; } } } + if (pdfFW) { + data = [[pdfFW regularFileContents] retain]; + pdfDoc = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:[[absoluteURL path] stringByAppendingPathComponent:[pdfFW filename]]]]; + } + if (skimFW) { + if (noteArray = [NSKeyedUnarchiver unarchiveObjectWithData:[skimFW regularFileContents]]) + [self setNoteDicts:noteArray]; + } [fileWrapper release]; } else if ([docType isEqualToString:SKPostScriptDocumentType]) { if (data = [NSData dataWithContentsOfURL:absoluteURL options:NSUncachedRead error:&error]) { 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