[fbcocoa] Re: NSTask & gzip

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2010 : Group Archive : Group : All Groups

From: Bernie <fbcocoa.bw@...>
Date: Sun, 28 Nov 2010 18:46:13 +0000
I wrote:

> Have used NSTask to execute Terminal commands before but having trouble with gzip. I'm guessing my arguments are not set up correctly. Anyone see what's wrong in this example?
> < code snip >


'ditto' works:
'---------------
include "Util_FileDirectory.incl"

BeginCFunction
void ZipFile( CFStringRef inPath )
{
 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 NSTask *task = [[[NSTask alloc] init] autorelease];
 [task setLaunchPath:@"/usr/bin/ditto"];
	NSString *outPath = [(NSString *)inPath stringByAppendingString:@".zip"];
 [task setArguments:[NSArray arrayWithObjects:@"-c",(NSString *)inPath,outPath,nil]];
 [task waitUntilExit];
 [task launch];
 [pool drain];
}
EndC
toolbox ZipFile( CFStringRef inPath )

dim as FSRef ref
dim as CFStringRef path

long if ( files$( _FSRefOpen,,, ref ) )
fn FD_FSRefCreatePath( @ref, @path )
ZipFile( path )
CFRelease( path )
end if

RunApplicationEventLoop()
'---------------

Would still like to know why gzip doesn't work with NSTask (anyone?).

Bernie