|
|
Using usr/bin/zip in NSTask
|
|
|
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
Hi,
I am not very good with command line tools and am wondering if someone can help me create an zip archive of the Desktop folder using usr/bin/zip and NSTask.
I have gotten this far (see below), but since I don't really know how to use usr/bin/zip in the command line I don't know how to create my NSTask.
//begin sample code
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/zip"];
//should this be "/usr/bin/zip ~/Desktop" or something like that? how do you create an zip archive from the command line?
NSPipe *pipe;
pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
[task launch];
//end sample code
Thanks for the help.
|
|
|
|
|
|
|
|
|
Fresh-Faced Recruit
Join Date: Jul 2006
Status:
Offline
|
|
If you drop to a terminal prompt and just type 'zip' you will get a list of the commandline switches. Basically if you want to zip up a directory and all it's subdirectories you need something like:
zip -r desktop.zip ~/desktop/*
-r means 'recurse directories' so you get folders copied too
desktop.zip is the name of the file to create.. you'll probably want to put a path in there too
~/desltop/* means zip up everything on the current user's desktop
Hope that helps.
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status:
Offline
|
|
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
And you don't want to put the arguments in the NSTask launch path. Check out the NSTask documentation for how to set arguments.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|