Improve unzipping progress delegate
This commit is contained in:
+3
-1
@@ -36,7 +36,9 @@
|
||||
|
||||
@optional
|
||||
|
||||
- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path globalInfo:(unz_global_info)globalInfo;
|
||||
- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo;
|
||||
- (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath;
|
||||
|
||||
- (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
|
||||
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo;
|
||||
|
||||
|
||||
+7
-5
@@ -70,15 +70,12 @@
|
||||
unsigned char buffer[4096] = {0};
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSMutableSet *directoriesModificationDates = [[NSMutableSet alloc] init];
|
||||
if([delegate respondsToSelector:@selector(zipArchiveWillUnzipFile:globalInfo:)])
|
||||
[delegate zipArchiveWillUnzipFile:path globalInfo:globalInfo];
|
||||
|
||||
// Message delegate
|
||||
if ([delegate respondsToSelector:@selector(zipArchiveWillUnzipArchiveAtPath:globalInfo:)]) {
|
||||
[delegate zipArchiveWillUnzipArchiveAtPath:path globalInfo:globalInfo];
|
||||
if ([delegate respondsToSelector:@selector(zipArchiveWillUnzipArchiveAtPath:zipInfo:)]) {
|
||||
[delegate zipArchiveWillUnzipArchiveAtPath:path zipInfo:globalInfo];
|
||||
}
|
||||
|
||||
NSMutableSet *directoriesModificationDates = [[NSMutableSet alloc] init];
|
||||
NSInteger currentFileNumber = 0;
|
||||
do {
|
||||
if ([password length] == 0) {
|
||||
@@ -208,6 +205,11 @@
|
||||
[directoriesModificationDates release];
|
||||
#endif
|
||||
|
||||
// Message delegate
|
||||
if (success && [delegate respondsToSelector:@selector(zipArchiveDidUnzipArchiveAtPath:zipInfo:unzippedPath:)]) {
|
||||
[delegate zipArchiveDidUnzipArchiveAtPath:path zipInfo:globalInfo unzippedPath:destination];
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
B215FB6A143AD576003AC546 /* unzip.c in Sources */ = {isa = PBXBuildFile; fileRef = B215FB53143AD460003AC546 /* unzip.c */; };
|
||||
B215FB6B143AD576003AC546 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = B215FB55143AD460003AC546 /* zip.c */; };
|
||||
B215FB6D143AD6FF003AC546 /* TestArchive.zip in Resources */ = {isa = PBXBuildFile; fileRef = B215FB6C143AD6FF003AC546 /* TestArchive.zip */; };
|
||||
B23FCC751558EEBE0026375C /* Views.zip in Resources */ = {isa = PBXBuildFile; fileRef = B23FCC741558EEBE0026375C /* Views.zip */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -39,6 +40,7 @@
|
||||
B215FB61143AD514003AC546 /* SSZipArchiveTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSZipArchiveTests.m; sourceTree = "<group>"; };
|
||||
B215FB64143AD527003AC546 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
|
||||
B215FB6C143AD6FF003AC546 /* TestArchive.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = TestArchive.zip; sourceTree = "<group>"; };
|
||||
B23FCC741558EEBE0026375C /* Views.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = Views.zip; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -113,6 +115,7 @@
|
||||
B215FB5E143AD505003AC546 /* SSZipArchiveTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
B23FCC741558EEBE0026375C /* Views.zip */,
|
||||
B215FB60143AD514003AC546 /* SSZipArchiveTests.h */,
|
||||
B215FB61143AD514003AC546 /* SSZipArchiveTests.m */,
|
||||
B215FB5F143AD514003AC546 /* SSZipArchiveTests-Info.plist */,
|
||||
@@ -174,6 +177,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
B215FB6D143AD6FF003AC546 /* TestArchive.zip in Resources */,
|
||||
B23FCC751558EEBE0026375C /* Views.zip in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
testPath = [outputPath stringByAppendingPathComponent:@"LICENSE"];
|
||||
STAssertTrue([fileManager fileExistsAtPath:testPath], @"LICENSE unzipped");
|
||||
|
||||
|
||||
// Commented out to avoid checking in several gig file into the repository. Simply add a file named
|
||||
// `LargeArchive.zip` to the project and uncomment out these lines to test.
|
||||
// zipPath = [[NSBundle bundleForClass:[self class]] pathForResource:@"LargeArchive" ofType:@"zip"];
|
||||
@@ -52,18 +52,23 @@
|
||||
|
||||
#pragma mark - Delegate
|
||||
|
||||
- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path globalInfo:(unz_global_info)globalInfo {
|
||||
NSLog(@"zipArchiveWillUnzipArchiveAtPath: `%@` globalInfo:", path);
|
||||
- (void)zipArchiveWillUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo {
|
||||
NSLog(@"zipArchiveWillUnzipArchiveAtPath: `%@` zipInfo:", path);
|
||||
}
|
||||
|
||||
|
||||
- (void)zipArchiveDidUnzipArchiveAtPath:(NSString *)path zipInfo:(unz_global_info)zipInfo unzippedPath:(NSString *)unzippedPath {
|
||||
NSLog(@"zipArchiveDidUnzipArchiveAtPath: `%@` zipInfo: unzippedPath: `%@`", path, unzippedPath);
|
||||
}
|
||||
|
||||
|
||||
- (void)zipArchiveWillUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo {
|
||||
NSLog(@"zipArchiveWillUnzipFileAtIndex: `%ld` totalFiles: `%ld` unzippedPath: `%@` fileInfo:", fileIndex, totalFiles, archivePath);
|
||||
NSLog(@"zipArchiveWillUnzipFileAtIndex: `%ld` totalFiles: `%ld` archivePath: `%@` fileInfo:", fileIndex, totalFiles, archivePath);
|
||||
}
|
||||
|
||||
|
||||
- (void)zipArchiveDidUnzipFileAtIndex:(NSInteger)fileIndex totalFiles:(NSInteger)totalFiles archivePath:(NSString *)archivePath fileInfo:(unz_file_info)fileInfo {
|
||||
NSLog(@"zipArchiveDidUnzipFileAtIndex: `%ld` totalFiles: `%ld` unzippedPath: `%@` fileInfo:", fileIndex, totalFiles, archivePath);
|
||||
NSLog(@"zipArchiveDidUnzipFileAtIndex: `%ld` totalFiles: `%ld` archivePath: `%@` fileInfo:", fileIndex, totalFiles, archivePath);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user