Skip to content

Commit

Permalink
Remove uses of dot notation for non properties of NSTask.
Browse files Browse the repository at this point in the history
  • Loading branch information
brotherbard committed Jun 27, 2010
1 parent 83e7c42 commit 1b3f4ea
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions PBEasyPipe.m
Expand Up @@ -19,10 +19,10 @@ + (NSFileHandle*) handleForCommand: (NSString*) cmd withArgs: (NSArray*) args
+ (NSTask *) taskForCommand:(NSString *)cmd withArgs:(NSArray *)args inDir:(NSString *)dir
{
NSTask* task = [[NSTask alloc] init];
task.launchPath = cmd;
task.arguments = args;
[task setLaunchPath:cmd];
[task setArguments:args];
if (dir)
task.currentDirectoryPath = dir;
[task setCurrentDirectoryPath:dir];

if ([[NSUserDefaults standardUserDefaults] boolForKey:@"Show Debug Messages"])
NSLog(@"Starting command `%@ %@` in dir %@", cmd, [args componentsJoinedByString:@" "], dir);
Expand All @@ -31,15 +31,15 @@ + (NSTask *) taskForCommand:(NSString *)cmd withArgs:(NSArray *)args inDir:(NSSt
#endif

NSPipe* pipe = [NSPipe pipe];
task.standardOutput = pipe;
task.standardError = pipe;
[task setStandardOutput:pipe];
[task setStandardError:pipe];
return task;
}

+ (NSFileHandle*) handleForCommand: (NSString*) cmd withArgs: (NSArray*) args inDir: (NSString*) dir
{
NSTask *task = [self taskForCommand:cmd withArgs:args inDir:dir];
NSFileHandle* handle = [task.standardOutput fileHandleForReading];
NSFileHandle* handle = [[task standardOutput] fileHandleForReading];

[task launch];
return handle;
Expand Down Expand Up @@ -76,14 +76,14 @@ + (NSString*) outputForCommand:(NSString *) cmd
if (dict) {
NSMutableDictionary *env = [[[NSProcessInfo processInfo] environment] mutableCopy];
[env addEntriesFromDictionary:dict];
task.environment = env;
[task setEnvironment:env];
}

NSFileHandle* handle = [task.standardOutput fileHandleForReading];
NSFileHandle* handle = [[task standardOutput] fileHandleForReading];

if (input) {
task.standardInput = [NSPipe pipe];
NSFileHandle *inHandle = [task.standardInput fileHandleForWriting];
[task setStandardInput:[NSPipe pipe]];
NSFileHandle *inHandle = [[task standardInput] fileHandleForWriting];
[inHandle writeData:[input dataUsingEncoding:NSUTF8StringEncoding]];
[inHandle closeFile];
}
Expand Down Expand Up @@ -111,10 +111,10 @@ + (NSString*) outputForCommand:(NSString *) cmd
+ (NSString*) outputForCommand: (NSString*) cmd withArgs: (NSArray*) args inDir: (NSString*) dir
{
NSTask *task = [self taskForCommand:cmd withArgs:args inDir:dir];
NSFileHandle* handle = [task.standardOutput fileHandleForReading];
NSFileHandle* handle = [[task standardOutput] fileHandleForReading];

[task launch];
#warning This can cause a "Bad file descriptor"... when?
// This can cause a "Bad file descriptor"... when?
NSData *data;
@try {
data = [handle readDataToEndOfFile];
Expand Down

0 comments on commit 1b3f4ea

Please sign in to comment.