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

NSTask & gzip

Posted by: Info <Info@...>

To compress more than one file into a single archive, use the '-c' option:

gzip -c filename1 filename2 > two-files.gz

This technique can be used to avoid replacing the original file:

gzip -c filename > filename.gz

The '-c' option is actually sending the compressed file to the terminal.

> From: Bernie <[email protected]>
> Reply-To: <[email protected]>
> Date: Sun, 28 Nov 2010 15:24:32 +0000
> To: <[email protected]>
> Subject: [fbcocoa] NSTask & gzip
>
>
> 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
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>