diff --git a/SSZipArchive/SSZipArchive.m b/SSZipArchive/SSZipArchive.m index d489dd1..65a18cb 100755 --- a/SSZipArchive/SSZipArchive.m +++ b/SSZipArchive/SSZipArchive.m @@ -657,7 +657,7 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo); + (BOOL)createZipFileAtPath:(NSString *)path withFilesAtPaths:(NSArray *)paths withPassword:(NSString *)password { SSZipArchive *zipArchive = [[SSZipArchive alloc] initWithPath:path]; - BOOL success = [zipArchive open]; + BOOL success = [zipArchive openWithSplitSize:0]; if (success) { for (NSString *filePath in paths) { success &= [zipArchive writeFile:filePath withPassword:password]; @@ -686,7 +686,7 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo); keepParentDirectory:(BOOL)keepParentDirectory withPassword:(nullable NSString *)password andProgressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler { - return [self createZipFileAtPath:path withContentsOfDirectory:directoryPath keepParentDirectory:keepParentDirectory compressionLevel:Z_DEFAULT_COMPRESSION password:password AES:YES progressHandler:progressHandler]; + return [self createZipFileAtPath:path withContentsOfDirectory:directoryPath keepParentDirectory:keepParentDirectory compressionLevel:Z_DEFAULT_COMPRESSION password:password AES:YES diskSize:0 progressHandler:progressHandler]; } + (BOOL)createZipFileAtPath:(NSString *)path @@ -695,10 +695,11 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo); compressionLevel:(int)compressionLevel password:(nullable NSString *)password AES:(BOOL)aes + diskSize:(int)diskSize progressHandler:(void(^ _Nullable)(NSUInteger entryNumber, NSUInteger total))progressHandler { SSZipArchive *zipArchive = [[SSZipArchive alloc] initWithPath:path]; - BOOL success = [zipArchive open]; + BOOL success = [zipArchive openWithSplitSize:diskSize]; if (success) { // use a local fileManager (queue/thread compatibility) NSFileManager *fileManager = [[NSFileManager alloc] init]; @@ -748,11 +749,13 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo); return self; } - -- (BOOL)open +- (BOOL)openWithSplitSize:(int)disk_size { NSAssert((_zip == NULL), @"Attempting to open an archive which is already open"); - _zip = zipOpen(_path.fileSystemRepresentation, APPEND_STATUS_CREATE); + if (disk_size < 1024) //avoid creating split of size < 1 KB + _zip = zipOpen(_path.fileSystemRepresentation, APPEND_STATUS_CREATE); + else + _zip = zipOpen3(_path.fileSystemRepresentation, APPEND_STATUS_CREATE, disk_size, NULL, NULL); return (NULL != _zip); }