Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Using usr/bin/zip in NSTask

Using usr/bin/zip in NSTask
Thread Tools
macrophyllum
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Jul 12, 2006, 08:52 AM
 
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.
     
Beepcake
Fresh-Faced Recruit
Join Date: Jul 2006
Status: Offline
Reply With Quote
Jul 12, 2006, 11:54 AM
 
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.
     
macrophyllum  (op)
Mac Enthusiast
Join Date: Sep 2000
Location: Vermont, USA
Status: Offline
Reply With Quote
Jul 12, 2006, 02:03 PM
 
Thank you very much.
     
Chuckit
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status: Offline
Reply With Quote
Jul 12, 2006, 02:43 PM
 
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 Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 05:13 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,