@@ -29,11 +29,21 @@ @implementation SSZipArchive {
29
29
#pragma mark - Unzipping
30
30
31
31
+ (BOOL )unzipFileAtPath : (NSString *)path toDestination : (NSString *)destination {
32
- return [self unzipFileAtPath: path toDestination: destination overwrite: YES password: nil error :nil ];
32
+ return [self unzipFileAtPath: path toDestination: destination delegate :nil ];
33
33
}
34
34
35
35
36
36
+ (BOOL )unzipFileAtPath : (NSString *)path toDestination : (NSString *)destination overwrite : (BOOL )overwrite password : (NSString *)password error : (NSError **)error {
37
+ return [self unzipFileAtPath: path toDestination: destination overwrite: overwrite password: password error: error delegate: nil ];
38
+ }
39
+
40
+
41
+ + (BOOL )unzipFileAtPath : (NSString *)path toDestination : (NSString *)destination delegate : (id <SSZipArchiveDelegate>)delegate {
42
+ return [self unzipFileAtPath: path toDestination: destination overwrite: YES password: nil error: nil delegate: delegate];
43
+ }
44
+
45
+
46
+ + (BOOL )unzipFileAtPath : (NSString *)path toDestination : (NSString *)destination overwrite : (BOOL )overwrite password : (NSString *)password error : (NSError **)error delegate : (id <SSZipArchiveDelegate>)delegate {
37
47
// Begin opening
38
48
zipFile zip = unzOpen ((const char *)[path UTF8String ]);
39
49
if (zip == NULL ) {
@@ -62,6 +72,7 @@ + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination o
62
72
NSFileManager *fileManager = [NSFileManager defaultManager ];
63
73
NSMutableSet *directoriesModificationDates = [[NSMutableSet alloc ] init ];
64
74
75
+ NSInteger currentFileNumber = 0 ;
65
76
do {
66
77
if ([password length ] == 0 ) {
67
78
ret = unzOpenCurrentFile (zip);
@@ -85,6 +96,8 @@ + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination o
85
96
break ;
86
97
}
87
98
99
+ [delegate zipArchiveWillUnzipFileNumber: currentFileNumber fromFile: path fileInfo: fileInfo];
100
+
88
101
char *filename = (char *)malloc (fileInfo.size_filename + 1 );
89
102
unzGetCurrentFileInfo (zip, &fileInfo, filename, fileInfo.size_filename + 1 , NULL , 0 , NULL , 0 );
90
103
filename[fileInfo.size_filename] = ' \0 ' ;
@@ -155,6 +168,8 @@ + (BOOL)unzipFileAtPath:(NSString *)path toDestination:(NSString *)destination o
155
168
156
169
unzCloseCurrentFile ( zip );
157
170
ret = unzGoToNextFile ( zip );
171
+
172
+ currentFileNumber++;
158
173
} while (ret == UNZ_OK && UNZ_OK != UNZ_END_OF_LIST_OF_FILE);
159
174
160
175
// Close
0 commit comments