0

I'm not really sure how to phrase this question, but I'll try my best. I have an NSTask that currently unzips an archive, and it needs to also support archives which might have a password. I have no idea how to go about pausing the task or how to detect if a password might be present, get the input if needed then proceed, or if this is even possible?

NSTask *unzip = [[NSTask alloc] init];
[unzip setLaunchPath:@"/usr/bin/unzip"];
[unzip setArguments:[NSArray arrayWithObjects:@"-u", @"-d", 
                     destination, zipFile, nil]];

NSPipe *aPipe = [[NSPipe alloc] init];
[unzip setStandardOutput:aPipe];

[unzip launch];

// if statement here?

[unzip waitUntilExit];
[unzip release];

From terminal stdout looks like this:

Archive: encrypted.zip
   creating: test
[encrypted.zip] test password: 
   skipping: test  incorrect password

Also I wish not to limit this to zip files, since I also use a similar task to untar/gzip archives. Is there are way to have the NSTask pop up a modal window if it detects an archive with a password or from certain stdout it might receive?

Yoshi Miro
  • 39
  • 5
  • Any interaction with the input/output will have to be dealt with by yourself in code by reading from the output and sending input via a pipe assigned using `setStandardInput:`. – Anya Shenanigans Sep 29 '15 at 15:32
  • @Petesh - Makes sense, any pointers as to how that could be accomplished? – Yoshi Miro Sep 29 '15 at 17:22
  • Read output character by character from the output and respond to it by opening an panel where you request password. Lots of code, no shortcut because the output from terminal is just whatever text (no standards). – Marek H Sep 29 '15 at 20:54

0 Answers0