Revision: 4263
          http://skim-app.svn.sourceforge.net/skim-app/?rev=4263&view=rev
Author:   hofman
Date:     2008-07-21 11:08:00 +0000 (Mon, 21 Jul 2008)

Log Message:
-----------
Better error messages from tool

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

Modified: trunk/SkimNotes/skimnotes.m
===================================================================
--- trunk/SkimNotes/skimnotes.m 2008-07-21 10:58:54 UTC (rev 4262)
+++ trunk/SkimNotes/skimnotes.m 2008-07-21 11:08:00 UTC (rev 4263)
@@ -99,7 +99,7 @@
     if (argc < 2) {
         WRITE_ERROR;
         [pool release];
-        exit (1);
+        exit(EXIT_FAILURE);
     }
     
     NSInteger action = SKNActionForName([args objectAtIndex:1]);
@@ -172,7 +172,7 @@
         if (argc < 3) {
             WRITE_ERROR;
             [pool release];
-            exit (1);
+            exit(EXIT_FAILURE);
         }
         
         NSString *formatString = nil;
@@ -183,7 +183,7 @@
             if (argc < 5) {
                 WRITE_ERROR;
                 [pool release];
-                exit (1);
+                exit(EXIT_FAILURE);
             }
             offset = 4;
             formatString = [args objectAtIndex:3];
@@ -216,7 +216,7 @@
         }
         
         if ([fm fileExistsAtPath:pdfPath isDirectory:&isDir] == NO || isBundle 
!= isDir) {
-            error = [NSError errorWithDomain:NSPOSIXErrorDomain code:ENOENT 
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"PDF file does not exist", 
NSLocalizedDescriptionKey, nil]];
+            error = [NSError errorWithDomain:NSPOSIXErrorDomain code:ENOENT 
userInfo:[NSDictionary dictionaryWithObjectsAndKeys:isBundle ? @"PDF bundle 
does not exist" : @"PDF file does not exist", NSLocalizedDescriptionKey, nil]];
         } else if (action == SKNActionGet) {
             NSData *data = nil;
             if (format == SKNFormatAuto) {
@@ -251,16 +251,20 @@
                     }
                 }
             }
-        } else if (action == SKNActionSet && notesPath && ([notesPath 
isEqualToString:STD_IN_OUT_FILE] || ([fm fileExistsAtPath:notesPath 
isDirectory:&isDir] && isDir == NO))) {
-            NSData *data = nil;
-            if ([notesPath isEqualToString:STD_IN_OUT_FILE])
-                data = [[NSFileHandle fileHandleWithStandardInput] 
readDataToEndOfFile];
-            else
-                data = [NSData dataWithContentsOfFile:notesPath];
-            if ([data length])
-                success = [fm writeSkimNotes:data textNotes:nil RTFNotes:nil 
atPath:pdfPath error:&error];
-            else if (data)
-                success = [fm removeSkimNotesAtPath:pdfPath error:&error];
+        } else if (action == SKNActionSet) {
+            if (notesPath && ([notesPath isEqualToString:STD_IN_OUT_FILE] || 
([fm fileExistsAtPath:notesPath isDirectory:&isDir] && isDir == NO))) {
+                NSData *data = nil;
+                if ([notesPath isEqualToString:STD_IN_OUT_FILE])
+                    data = [[NSFileHandle fileHandleWithStandardInput] 
readDataToEndOfFile];
+                else
+                    data = [NSData dataWithContentsOfFile:notesPath];
+                if ([data length])
+                    success = [fm writeSkimNotes:data textNotes:nil 
RTFNotes:nil atPath:pdfPath error:&error];
+                else if (data)
+                    success = [fm removeSkimNotesAtPath:pdfPath error:&error];
+            } else {
+                error = [NSError errorWithDomain:NSPOSIXErrorDomain 
code:ENOENT userInfo:[NSDictionary dictionaryWithObjectsAndKeys:@"Notes file 
does not exist", NSLocalizedDescriptionKey, nil]];
+            }
         } else if (action == SKNActionRemove) {
             success = [fm removeSkimNotesAtPath:pdfPath error:&error];
         } else if (action == SKNActionConvert) {
@@ -294,5 +298,5 @@
     
     [pool release];
     
-    return success ? 0 : 1;
+    return success ? EXIT_SUCCESS : EXIT_FAILURE;
 }


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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to