Revision: 7814
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7814&view=rev
Author:   hofman
Date:     2012-12-06 18:21:45 +0000 (Thu, 06 Dec 2012)
Log Message:
-----------
Use URL based method to get files inside PDF bundles

Modified Paths:
--------------
    trunk/SKDocumentController.m
    trunk/SKFileUpdateChecker.m
    trunk/SKMainDocument.m

Modified: trunk/SKDocumentController.m
===================================================================
--- trunk/SKDocumentController.m        2012-12-06 18:03:16 UTC (rev 7813)
+++ trunk/SKDocumentController.m        2012-12-06 18:21:45 UTC (rev 7814)
@@ -268,8 +268,8 @@
                 NSData *data = nil;
                 
                 if ([[NSWorkspace sharedWorkspace] type:type 
conformsToType:SKPDFBundleDocumentType]) {
-                    NSString *skimFile = [[NSFileManager defaultManager] 
bundledFileWithExtension:@"skim" inPDFBundleAtPath:[theURL path] error:&error];
-                    data = skimFile ? [NSData dataWithContentsOfFile:skimFile 
options:0 error:&error] : nil;
+                    NSURL *skimFileURL = [[NSFileManager defaultManager] 
bundledFileURLWithExtension:@"skim" inPDFBundleAtURL:theURL error:&error];
+                    data = skimFileURL ? [NSData 
dataWithContentsOfURL:skimFileURL options:0 error:&error] : nil;
                 } else {
                     data = [[SKNExtendedAttributeManager sharedManager] 
extendedAttributeNamed:SKIM_NOTES_KEY atPath:[theURL path] traverseLink:YES 
error:&error];
                 }

Modified: trunk/SKFileUpdateChecker.m
===================================================================
--- trunk/SKFileUpdateChecker.m 2012-12-06 18:03:16 UTC (rev 7813)
+++ trunk/SKFileUpdateChecker.m 2012-12-06 18:21:45 UTC (rev 7814)
@@ -188,10 +188,9 @@
         NSWorkspace *ws = [NSWorkspace sharedWorkspace];
         NSString *theUTI = [ws typeOfFile:[[[fileURL URLByStandardizingPath] 
URLByResolvingSymlinksInPath] path] error:NULL];
         if ([extension isCaseInsensitiveEqual:@"pdfd"] || [ws type:theUTI 
conformsToType:@"net.sourceforge.skim-app.pdfd"]) {
-            NSString *fileName = [[NSFileManager defaultManager] 
bundledFileWithExtension:@"pdf" inPDFBundleAtPath:[fileURL path] error:NULL];
-            if (fileName == nil)
+            fileURL = [[NSFileManager defaultManager] 
bundledFileURLWithExtension:@"pdf" inPDFBundleAtURL:fileURL error:NULL];
+            if (fileURL == nil)
                 return NO;
-            fileURL = [NSURL fileURLWithPath:fileName];
         } else if ([extension isCaseInsensitiveEqual:@"dvi"] || [extension 
isCaseInsensitiveEqual:@"xdv"]) {
             isDVI = YES;
         }

Modified: trunk/SKMainDocument.m
===================================================================
--- trunk/SKMainDocument.m      2012-12-06 18:03:16 UTC (rev 7813)
+++ trunk/SKMainDocument.m      2012-12-06 18:21:45 UTC (rev 7814)
@@ -648,11 +648,10 @@
         else
             error = [NSError 
writeFileErrorWithLocalizedDescription:NSLocalizedString(@"Unable to write 
notes as text", @"Error description")];
     } else if ([ws type:SKNotesFDFDocumentType conformsToType:typeName]) {
-        NSString *filePath = [[self fileURL] path];
-        NSString *filename = [filePath lastPathComponent];
-        if (filename && [ws type:[self fileType] 
conformsToType:SKPDFBundleDocumentType])
-            filename = [[NSFileManager defaultManager] 
bundledFileWithExtension:@"pdf" inPDFBundleAtPath:filePath error:NULL];
-        NSData *data = [self notesFDFDataForFile:filename fileIDStrings:[[self 
pdfDocument] fileIDStrings:pdfData]];
+        NSURL *fileURL = [self fileURL];
+        if (fileURL && [ws type:[self fileType] 
conformsToType:SKPDFBundleDocumentType])
+            fileURL = [[NSFileManager defaultManager] 
bundledFileURLWithExtension:@"pdf" inPDFBundleAtURL:fileURL error:NULL];
+        NSData *data = [self notesFDFDataForFile:[fileURL lastPathComponent] 
fileIDStrings:[[self pdfDocument] fileIDStrings:pdfData]];
         if (data)
             didWrite = [data writeToURL:absoluteURL options:0 error:&error];
         else 
@@ -771,10 +770,8 @@
     tmpData = [[SKTemporaryData alloc] init];
     
     if ([ws type:docType conformsToType:SKPDFBundleDocumentType]) {
-        NSString *path = [absoluteURL path];
-        NSString *pdfFile = [[NSFileManager defaultManager] 
bundledFileWithExtension:@"pdf" inPDFBundleAtPath:path error:&error];
-        if (pdfFile) {
-            NSURL *pdfURL = [NSURL fileURLWithPath:pdfFile];
+        NSURL *pdfURL = [[NSFileManager defaultManager] 
bundledFileURLWithExtension:@"pdf" inPDFBundleAtURL:absoluteURL error:&error];
+        if (pdfURL) {
             if ((data = [[NSData alloc] initWithContentsOfURL:pdfURL 
options:NSDataReadingUncached error:&error]) &&
                 (pdfDoc = [[SKPDFDocument alloc] initWithURL:pdfURL])) {
                 NSArray *array = [[NSFileManager defaultManager] 
readSkimNotesFromPDFBundleAtURL:absoluteURL error:&error];
@@ -783,7 +780,7 @@
                                                      
defaultButton:NSLocalizedString(@"No", @"Button title")
                                                    
alternateButton:NSLocalizedString(@"Yes", @"Button title")
                                                        otherButton:nil
-                                         
informativeTextWithFormat:NSLocalizedString(@"Skim was not able to read the 
notes at %@. %@ Do you want to continue to open the PDF document anyway?", 
@"Informative text in alert dialog"), [path 
stringByAbbreviatingWithTildeInPath], [error localizedDescription]];
+                                         
informativeTextWithFormat:NSLocalizedString(@"Skim was not able to read the 
notes at %@. %@ Do you want to continue to open the PDF document anyway?", 
@"Informative text in alert dialog"), [[pdfURL path] 
stringByAbbreviatingWithTildeInPath], [error localizedDescription]];
                     if ([alert runModal] == NSAlertDefaultReturn) {
                         SKDESTROY(data);
                         SKDESTROY(pdfDoc);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to