NSTask & gzip
Quote from Forum Archives on November 28, 2010, 10:24 amPosted 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 pathlong if ( files$( _FSRefOpen,,, ref ) )
fn FD_FSRefCreatePath( @ref, @path )
ZipFile( path )
CFRelease( path )
end ifRunApplicationEventLoop()
'---------------Bernie
Posted by: fbcocoa.bw <fbcocoa.bw@...>
'---------------
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