-
Notifications
You must be signed in to change notification settings - Fork 2
/
TaskController.m
executable file
·31 lines (23 loc) · 898 Bytes
/
TaskController.m
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
#import "TaskController.h"
@implementation TaskController
- (NSTask *)processFile:(NSString *)filePath toPath:(NSString *)extractPath;
{
NSTask *aTask = [[NSTask alloc] init];
NSMutableArray *args = [NSMutableArray array];
NSPipe *taskPipe = [NSPipe pipe];
NSString *command = @"x";
/* set standard I/O, here to a NSPipe */
[aTask setStandardOutput:taskPipe];
[aTask setStandardError:taskPipe];
/* set arguments */
[args addObject:command];
[args addObject:filePath];
[args addObject:extractPath];
[aTask setArguments:args];
/* set the path of the executable */
[aTask setLaunchPath:[[NSBundle mainBundle] pathForResource:@"unrar" ofType:nil]];
/* we want taskPipe to send notifications to be able to grab the output */
[[taskPipe fileHandleForReading] readInBackgroundAndNotify];
return aTask;
}
@end