PRHTask / PRHTask.h

//
//  PRHTask.h
//  Revision Switcher
//
//  Created by Peter Hosey on 2011-10-13.
//  Copyright 2011 Peter Hosey. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef void (^PRHTerminationBlock)(NSTask *task);

@interface PRHTask : NSTask

//For directing output to /dev/null.
- (void) nullifyStandardOutput;
- (void) nullifyStandardError;

//Don't attempt to interact with NSTask's standard{Output,Error} properties if you touch these standard-{output,error} properties.

//Set either or both of these before launch to have normal or error output accumulate in the appropriate data object.
@property(nonatomic) BOOL accumulatesStandardOutput, accumulatesStandardError;

//“Whitespace” here includes line breaks (whitespaceAndNewlineCharacterSet). Applies to both output and error output. Only affects the string properties; the data properties always contain the full output unmolested. Defaults to YES.
@property(nonatomic) BOOL trimWhitespaceFromAccumulatedOutputs;

//You probably should only use these after the task exits.
//You can expect the string properties to return nil if the output data is not valid UTF-8.
@property(nonatomic, readonly) NSData *accumulatedStandardOutputData;
@property(nonatomic, readonly) NSString *outputStringFromStandardOutputUTF8;
@property(nonatomic, readonly) NSData *accumulatedStandardErrorData;
@property(nonatomic, readonly) NSString *errorOutputStringFromStandardErrorUTF8;

@property(nonatomic, readonly, retain) NSError *standardOutputReadError, *standardErrorReadError;

#pragma mark -

@property(copy) PRHTerminationBlock successfulTerminationBlock;
@property(copy) PRHTerminationBlock abnormalTerminationBlock;

@end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.