forked from pypt/FreeDMG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFDTaskWrapper.h
81 lines (54 loc) · 2.66 KB
/
FDTaskWrapper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
File: FDTaskWrapper.h
Description: This class is a generalized process handling class that makes asynchronous interaction with an NSTask easier.
There is also a protocol designed to work in conjunction with the TaskWrapper class;
your process controller should conform to this protocol.
TaskWrapper objects are one-shot (since NSTask is one-shot);
if you need to run a task more than once, destroy/create new TaskWrapper objects.
Descended from Apple sample source.
Modified for use with FreeDMG <http://www.kelleycomputing.net/freedmg>
Copyright (C) 2004-2008 Eddie Kelley <[email protected]>
This file is part of FreeDMG
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <Foundation/Foundation.h>
@protocol FDTaskWrapperController
// Your controller's implementation of this method will be called when output arrives from the NSTask.
// Output will come from both stdout and stderr, per the TaskWrapper implementation.
- (void)appendOutput:(NSString *)output;
// This method is a callback which your controller can use to do other initialization when a process
// is launched.
- (void)processStarted;
// This method is a callback which your controller can use to do other cleanup when a process
// is halted.
- (void)processFinished;
@end
@interface FDTaskWrapper : NSObject {
NSTask *task;
id <FDTaskWrapperController>controller;
NSArray *arguments;
}
// This is the designated initializer - pass in your controller and any task arguments.
// The first argument should be the path to the executable to launch with the NSTask.
- (id)initWithController:(id <FDTaskWrapperController>)controller arguments:(NSArray *)args;
// This method launches the process, setting up asynchronous feedback notifications.
- (void) startProcess;
// This method stops the process, stoping asynchronous feedback notifications.
- (void) stopProcess;
// returns task termination status
-(int)terminationStatus;
// returns a task's process identifier
-(int)processID;
// returns true if a process is currently running
-(BOOL)isRunning;
-(void) waitUntilExit;
@end