• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
NSTask with unzip
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSTask with unzip


  • Subject: NSTask with unzip
  • From: "gMail.com" <email@hidden>
  • Date: Fri, 26 Nov 2010 13:33:58 +0100
  • Thread-topic: NSTask with unzip

Hi, I can properly unzip a zip file launching a NSTask with /usr/bin/unzip
The task saves the unzipped file to the disk, then a I read the unzipped
file in a NSData. Well. My question is:
Can I do the same job without saving the unzipped file to the disk?

I have tried to set the standard output to a pipe - which works well with
other tasks - but here it doesn't work. The task never exits. Here's the
wrong code:

NSTask *unzip = [[[NSTask alloc] init] autorelease];
[unzip setLaunchPath:@"/usr/bin/unzip"];
[unzip setArguments:[NSArray arrayWithObjects:@"-p", zipfile,
@"filetounzip", nil]];

NSPipe *aPipe = [NSPipe pipe];
[unzip setStandardOutput:aPipe];
[unzip launch];
[unzip waitUntilExit];

if([unzip terminationStatus] == noErr){
     dictData = [NSMutableData data];
     while((dataOut = [aPipe availableData]) && [dataOut length]){
         [dictData appendData:dataOut];
     }
}


-- Leo


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSTask with unzip
      • From: Ben Haller <email@hidden>
  • Prev by Date: Re: respondsToSelector & "warning: may not respond"
  • Next by Date: Re: how to redraw a view
  • Previous by thread: Re: respondsToSelector & "warning: may not respond"
  • Next by thread: Re: NSTask with unzip
  • Index(es):
    • Date
    • Thread