Revision: 3276
          http://skim-app.svn.sourceforge.net/skim-app/?rev=3276&view=rev
Author:   hofman
Date:     2007-11-27 08:58:14 -0800 (Tue, 27 Nov 2007)

Log Message:
-----------
Use hdiutil directly to create a disk image on Leopard. 

Modified Paths:
--------------
    trunk/SKDocument.m

Modified: trunk/SKDocument.m
===================================================================
--- trunk/SKDocument.m  2007-11-26 20:59:42 UTC (rev 3275)
+++ trunk/SKDocument.m  2007-11-27 16:58:14 UTC (rev 3276)
@@ -860,15 +860,9 @@
     
     if (NSOKButton == returnCode && [self fileURL]) {
                             
-        @try {            
-            // create a tar archive; make sure we use a relative path in the 
archive
-            [NSTask runTaskWithLaunchPath:@"/usr/bin/tar"
-                                arguments:[NSArray arrayWithObjects:@"-czf", 
[sheet filename], [[[self fileURL] path] lastPathComponent], nil]
-                     currentDirectoryPath:[[[self fileURL] path] 
stringByDeletingLastPathComponent]];
-        }
-        @catch(id exception) {
-            NSLog(@"caught exception %@ while archiving %@ to %@", exception, 
[[self fileURL] path], [sheet filename]);
-        }
+        [NSTask runTaskWithLaunchPath:@"/usr/bin/tar"
+                            arguments:[NSArray arrayWithObjects:@"-czf", 
[sheet filename], [[[self fileURL] path] lastPathComponent], nil]
+                 currentDirectoryPath:[[[self fileURL] path] 
stringByDeletingLastPathComponent]];
     }
 }
 
@@ -891,22 +885,28 @@
 }
 
 - (void)saveDiskImageWithInfo:(NSDictionary *)info {
-        
-        NSAutoreleasePool *pool = [NSAutoreleasePool new];
-        
-        NSString *sourcePath = [[[info objectForKey:@"sourcePath"] copy] 
autorelease];
-        NSString *targetPath = [[[info objectForKey:@"targetPath"] copy] 
autorelease];
-        NSString *scriptPath = [[[NSBundle mainBundle] sharedSupportPath] 
stringByAppendingPathComponent:@"archivedmg.sh"];
-        NSTask *task = [NSTask launchedTaskWithLaunchPath:scriptPath 
arguments:[NSArray arrayWithObjects:sourcePath, targetPath, nil]];
-        
-        if ([task isRunning])
-            [task waitUntilExit];
-        if ([task isRunning])
-            [task terminate];
-        
-        [[self progressController] performSelectorOnMainThread:@selector(hide) 
withObject:nil waitUntilDone:NO];
-        
-        [pool release];
+    
+    NSAutoreleasePool *pool = [NSAutoreleasePool new];
+    
+    NSString *sourcePath = [[[info objectForKey:@"sourcePath"] copy] 
autorelease];
+    NSString *targetPath = [[[info objectForKey:@"targetPath"] copy] 
autorelease];
+    NSString *scriptPath = nil;
+    NSArray *arguments = nil;
+    
+    if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_4) {
+        // hdiutil on Tiger looses EAs, so we use a more complicated path
+        scriptPath = [[[NSBundle mainBundle] sharedSupportPath] 
stringByAppendingPathComponent:@"archivedmg.sh"];
+        arguments = [NSArray arrayWithObjects:sourcePath, targetPath, nil];
+    } else {
+        scriptPath = @"/usr/bin/hdiutil";
+        arguments = [NSArray arrayWithObjects:@"create", @"-srcfolder", 
sourcePath, @"-format", @"UDZO", @"-volname", [[targetPath lastPathComponent] 
stringByDeletingPathExtension], targetPath, nil];
+    }
+    
+    [NSTask runTaskWithLaunchPath:scriptPath arguments:arguments 
currentDirectoryPath:[sourcePath stringByDeletingLastPathComponent]];
+    
+    [[self progressController] performSelectorOnMainThread:@selector(hide) 
withObject:nil waitUntilDone:NO];
+    
+    [pool release];
 }
 
 - (void)diskImageSavePanelDidEnd:(NSSavePanel *)sheet 
returnCode:(int)returnCode  contextInfo:(void  *)contextInfo {


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: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to