Merge pull request #131 from soffes/zlandau-cancelunzip

Zlandau cancelunzip
This commit is contained in:
Douglas Bumby
2015-04-06 13:44:27 -04:00
3 changed files with 73 additions and 2 deletions
+12 -2
View File
@@ -72,6 +72,7 @@
}
BOOL success = YES;
BOOL canceled = NO;
int ret = 0;
unsigned char buffer[4096] = {0};
NSFileManager *fileManager = [NSFileManager defaultManager];
@@ -113,6 +114,15 @@
currentPosition += fileInfo.compressed_size;
// Message delegate
if ([delegate respondsToSelector:@selector(zipArchiveShouldUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) {
if (![delegate zipArchiveShouldUnzipFileAtIndex:currentFileNumber
totalFiles:(NSInteger)globalInfo.number_entry
archivePath:path fileInfo:fileInfo]) {
success = NO;
canceled = YES;
break;
}
}
if ([delegate respondsToSelector:@selector(zipArchiveWillUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) {
[delegate zipArchiveWillUnzipFileAtIndex:currentFileNumber totalFiles:(NSInteger)globalInfo.number_entry
archivePath:path fileInfo:fileInfo];
@@ -293,8 +303,8 @@
[delegate zipArchiveDidUnzipArchiveAtPath:path zipInfo:globalInfo unzippedPath:destination];
}
// final progress event = 100%
if ([delegate respondsToSelector:@selector(zipArchiveProgressEvent:total:)]) {
[delegate zipArchiveProgressEvent:(NSInteger)fileSize total:(NSInteger)fileSize];
if (!canceled && [delegate respondsToSelector:@selector(zipArchiveProgressEvent:total:)]) {
[delegate zipArchiveProgressEvent:fileSize total:fileSize];
}
return success;