Re: NSTask failing
Re: NSTask failing
- Subject: Re: NSTask failing
- From: "Hamish Allan" <email@hidden>
- Date: Fri, 4 Apr 2008 22:14:26 +0100
On Fri, Apr 4, 2008 at 9:20 PM, Randall Meadows <email@hidden> wrote:
> NSArray *args = [NSArray arrayWithObjects:
> @"-cf",
> [NSString stringWithFormat:@"\"%@\"", tarFilePath],
> [NSString stringWithFormat:@"\"%@\"", plistPath],
> nil];
> tarTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/tar"
> arguments:args];
> [tarTask waitUntilExit];
> int status = [tarTask terminationStatus];
Try:
NSArray *args = [NSArray arrayWithObjects: @"cfv", tarFilePath, plistPath, nil];
tarTask = [[[NSTask alloc] init] autorelease];
[tarTask setLaunchPath:@"/usr/bin/tar"];
[tarTask setArguments:args];
NSPipe *resultsPipe = [NSPipe pipe];
NSFileHandle *resultsHandle = [resultsPipe fileHandleForReading];
[tarTask setStandardOutput:resultsPipe];
[tarTask setStandardError:resultsPipe];
NSData *data;
while ([((data = [resultsHandle availableData])) length] > 0)
{
NSString *s = [[NSString alloc] initWithData:data
encoding:NSASCIIStringEncoding];
NSLog(s);
}
[tarTask waitUntilExit];
_______________________________________________
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