* Optimized Olivier's MYDirectoryWatcher fix (by caching the watcher's standardized path)
* Added -[NSData my_UTF8ToString] to CollectionUtils.
5 // Copyright 2008 Jens Alfke. All rights reserved.
8 #import <Cocoa/Cocoa.h>
11 extern NSString* const MYTaskErrorDomain;
12 extern NSString* const MYTaskExitCodeKey;
13 extern NSString* const MYTaskObjectKey;
20 @interface MYTask : NSObject
24 NSMutableArray *_arguments;
25 NSString *_currentDirectoryPath;
30 NSFileHandle *_outHandle, *_errHandle;
31 NSMutableData *_outputData, *_errorData;
33 NSMutableArray *_modes;
34 BOOL _isRunning, _taskRunning;
37 - (id) initWithCommand: (NSString*)subcommand, ... NS_REQUIRES_NIL_TERMINATION;
39 /* designated initializer (subclasses can override) */
40 - (id) initWithCommand: (NSString*)subcommand
41 arguments: (NSArray*)arguments;
43 - (id) initWithError: (NSError*)error;
45 - (void) addArgument: (id)argument;
46 - (void) addArguments: (id)arg1, ... NS_REQUIRES_NIL_TERMINATION;
47 - (void) addArgumentsFromArray: (NSArray*)arguments;
48 - (void) prependArguments: (id)arg1, ... NS_REQUIRES_NIL_TERMINATION;
50 - (void) ignoreOutput;
52 @property (copy) NSString* currentDirectoryPath;
54 /** Prettified description of command string. Doesn't do full shell-style quoting, though. */
55 - (NSString*) commandLine;
58 - (BOOL) run: (NSError**)outError;
62 - (BOOL) waitTillFinished;
64 @property (readonly,nonatomic) BOOL isRunning;
65 @property (readonly,retain,nonatomic) NSError* error;
66 @property (readonly,nonatomic) NSString *output, *outputAndError;
67 @property (readonly,nonatomic) NSData *outputData;
71 /** Subclasses can override this to add arguments or customize the task */
72 - (NSTask*) createTask;
74 /** Sets the error based on the message and parameters. Always returns NO. */
75 - (BOOL) makeError: (NSString*)fmt, ...;
77 /** Called when the task finishes, just before the isRunning property changes back to NO.
78 You can override this to do your own post-processing. */