I have to decode a uuencoded NSString in memory so I use NSTask to launch
the unix command uudecode. If I set the output to a file, it works. But if I
setStandardOutput to a NSFileHandle I cannot later get any availableData.
Can you please tell me why?
// -p should set the standard output. Even without this args, it fails.
NSArray *args = [NSArray arrayWithObjects:@"-p", nil];
[task setLaunchPath:@"/usr/bin/uudecode"];
[task setArguments:args];
I set the Standard input to the handle managing the string
NSPipe *writePipe = [NSPipe pipe];
NSFileHandle *writeHandle = [writePipe fileHandleForWriting];
[task setStandardInput:writePipe];
[writeHandle writeData:[uuencodedString
dataUsingEncoding:NSMacOSRomanStringEncoding]];
[writeHandle closeFile];
I set a StandardOutput to a readHandle
NSPipe *readPipe = [NSPipe pipe];
NSFileHandle *readHandle = [readPipe fileHandleForReading];
[task setStandardOutput:readHandle];
Then I launch and wait
[task launch];
[task waitUntilExit];
I cannot later get any data with
NSData *dataOut = [readHandle availableData];
The application doesn't go further. It remains blocked here.
What do I miss? Please note that if I set the standard output to a file
NSArray *args = [NSArray arrayWithObjects:@"-o", outFilePath, nil];
it properly works.
--
Leonardo
_______________________________________________
Cocoa-dev mailing list ([email protected])
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to [email protected]