diff --git a/SSZipArchive/SSZipArchive.h b/SSZipArchive/SSZipArchive.h index 8c77bd1..708ca16 100755 --- a/SSZipArchive/SSZipArchive.h +++ b/SSZipArchive/SSZipArchive.h @@ -61,7 +61,6 @@ NS_ASSUME_NONNULL_BEGIN + (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(nullable NSString *)password; + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath withPassword:(nullable NSString *)password; + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password; -+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler; - (instancetype)initWithPath:(NSString *)path; @property (NS_NONATOMIC_IOSONLY, readonly) BOOL open; diff --git a/SSZipArchive/SSZipArchive.m b/SSZipArchive/SSZipArchive.m index f9a5eb9..1960b64 100755 --- a/SSZipArchive/SSZipArchive.m +++ b/SSZipArchive/SSZipArchive.m @@ -591,15 +591,6 @@ + (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password{ - return [self createZipFileAtPath:password - withContentsOfDirectory:directoryPath - keepParentDirectory:keepParentDirectory - withPassword:password - andProgressHandler:nil - ]; -} - -+ (BOOL)createZipFileAtPath:(NSString *)path withContentsOfDirectory:(NSString *)directoryPath keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler { BOOL success = NO; NSFileManager *fileManager = nil; @@ -609,10 +600,8 @@ // use a local filemanager (queue/thread compatibility) fileManager = [[NSFileManager alloc] init]; NSDirectoryEnumerator *dirEnumerator = [fileManager enumeratorAtPath:directoryPath]; - NSArray *allObjects = dirEnumerator.allObjects; - NSUInteger total = allObjects.count, complete = 0; NSString *fileName; - for (fileName in allObjects) { + while ((fileName = [dirEnumerator nextObject])) { BOOL isDir; NSString *fullFilePath = [directoryPath stringByAppendingPathComponent:fileName]; [fileManager fileExistsAtPath:fullFilePath isDirectory:&isDir]; @@ -634,10 +623,6 @@ [zipArchive writeFileAtPath:tempFilePath withFileName:tempFileFilename withPassword:password]; } } - complete++; - if (progressHandler) { - progressHandler(complete, total); - } } success = [zipArchive close]; } @@ -900,4 +885,4 @@ return date; } -@end +@end \ No newline at end of file