-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNSBackgroundTaskUnzipTask.m
46 lines (35 loc) · 1.2 KB
/
NSBackgroundTaskUnzipTask.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#import "NSBackgroundTask.h"
#import "SSZipArchive.h"
@implementation NSBackgroundTaskUnzipTask
@synthesize delegate;
-(void) runTask{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@try{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSLog(@"unzip file %@ to %@", _fromFile, _toFile);
/*
if([fileManager fileExistsAtPath: destination ] == NO){
NSError *createError;
[fileManager createDirectoryAtPath:destination withIntermediateDirectories:NO
attributes:nil
error:&createError];
if(createError){
NSLog(@"create path error %@", createError);
return;
}
}*/
[SSZipArchive unzipFileAtPath:_fromFile toDestination:_toFile];
[self.delegate onComplete];
}@catch(NSException *exception){
NSLog(@"move file error %@", exception);
[self.delegate onError: [exception reason]];
}
});
}
-(id) initWithFromFile:(NSString *) fromFile toFile: (NSString *) toFile{
self = [super init];
_toFile = toFile;
_fromFile = fromFile;
return self;
}
@end