Forum Navigation
You need to log in to create posts and topics.

NSTask & gzip

Posted by: fbcocoa.bw <fbcocoa.bw@...>

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?

'---------------
include "Util_FileDirectory.incl"

BeginCFunction
void ZipFile( CFStringRef inPath )
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSTask *task = [[[NSTask alloc] init] autorelease];
[task setLaunchPath:@"/usr/bin/gzip"];
NSString *outPath = [[[NSString alloc] initWithFormat:@"%@.zip",(NSString *)inPath] autorelease];
[task setArguments:[NSArray arrayWithObjects:@"-c",@"-P",@"rotide",(NSString *)inPath,@">",outPath,nil]];
[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()
'---------------

Bernie