Revision: 4040
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4040&view=rev
Author:   hofman
Date:     2008-06-19 17:12:47 -0700 (Thu, 19 Jun 2008)

Log Message:
-----------
Add some more checking and return error when reading skim notes fails

Modified Paths:
--------------
    trunk/SkimNotes/NSFileManager_SKNExtensions.m

Modified: trunk/SkimNotes/NSFileManager_SKNExtensions.m
===================================================================
--- trunk/SkimNotes/NSFileManager_SKNExtensions.m       2008-06-19 17:36:00 UTC 
(rev 4039)
+++ trunk/SkimNotes/NSFileManager_SKNExtensions.m       2008-06-20 00:12:47 UTC 
(rev 4040)
@@ -162,9 +162,11 @@
         
         if ([data length])
             notes = [NSKeyedUnarchiver unarchiveObjectWithData:data];
+        else if ([error code] == ENOATTR)
+            notes = [NSArray array];
         
-        if (notes == nil)
-            notes = [NSArray array];
+        if (notes == nil && error != nil && outError) 
+            *outError = error;
     } else {
         if(error == nil && outError) 
             *outError = [NSError errorWithDomain:NSPOSIXErrorDomain 
code:ENOENT userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKNLocalizedString(@"The file does not exist or is 
not a file.", @"Error description"), NSLocalizedDescriptionKey, nil]];
@@ -180,8 +182,11 @@
 
         string = [[SKNExtendedAttributeManager sharedManager] 
propertyListFromExtendedAttributeNamed:SKIM_TEXT_NOTES_KEY atPath:[aURL path] 
traverseLink:YES error:&error];
         
-        if (string == nil)
+        if (string == nil && [error code] == ENOATTR)
             string = [NSString string];
+        
+        if (string == nil && error != nil && outError) 
+            *outError = error;
     } else {
         if(error == nil && outError) 
             *outError = [NSError errorWithDomain:NSPOSIXErrorDomain 
code:ENOENT userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKNLocalizedString(@"The file does not exist or is 
not a file.", @"Error description"), NSLocalizedDescriptionKey, nil]];
@@ -197,8 +202,11 @@
 
         data = [[SKNExtendedAttributeManager sharedManager] 
extendedAttributeNamed:SKIM_RTF_NOTES_KEY atPath:[aURL path] traverseLink:YES 
error:&error];
         
-        if (data == nil)
+        if (data == nil && [error code] == ENOATTR)
             data = [NSData data];
+        
+        if (data == nil && error != nil && outError) 
+            *outError = error;
     } else {
         if(error == nil && outError) 
             *outError = [NSError errorWithDomain:NSPOSIXErrorDomain 
code:ENOENT userInfo:[NSDictionary 
dictionaryWithObjectsAndKeys:SKNLocalizedString(@"The file does not exist or is 
not a file.", @"Error description"), NSLocalizedDescriptionKey, nil]];


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

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to