Compare commits
9 Commits
v2.1.0
...
IncorrectH
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ae03a2145 | ||
|
|
fab301b90f | ||
|
|
e5962afc05 | ||
|
|
236f31d25a | ||
|
|
01d1d9e770 | ||
|
|
1fd7fa9c29 | ||
|
|
2886108b12 | ||
|
|
45d2faf540 | ||
|
|
308b7c9849 |
@@ -68,9 +68,14 @@
|
||||
NSString *password = _passwordField.text;
|
||||
BOOL success = [SSZipArchive unzipFileAtPath:_zipPath
|
||||
toDestination:unzipPath
|
||||
preserveAttributes:YES
|
||||
overwrite:YES
|
||||
nestedZipLevel:0
|
||||
password:password.length > 0 ? password : nil
|
||||
error:nil];
|
||||
error:nil
|
||||
delegate:nil
|
||||
progressHandler:nil
|
||||
completionHandler:nil];
|
||||
if (success) {
|
||||
NSLog(@"Success unzip");
|
||||
} else {
|
||||
|
||||
@@ -240,10 +240,8 @@
|
||||
NSString *outputPath = [self _cachesPath:@"IncorrectHeaders"];
|
||||
|
||||
id<SSZipArchiveDelegate> delegate = [ProgressDelegate new];
|
||||
__unused BOOL success = [SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:delegate];
|
||||
// Temp disabled test, it's unclear if it's supposed to be a success of failure
|
||||
// as Z_BUF_ERROR is returned for "__MACOSX/IncorrectHeaders/._Readme.txt"
|
||||
//XCTAssertTrue(success);
|
||||
BOOL success = [SSZipArchive unzipFileAtPath:zipPath toDestination:outputPath delegate:delegate];
|
||||
XCTAssertTrue(success);
|
||||
|
||||
NSString *intendedReadmeTxtMD5 = @"31ac96301302eb388070c827447290b5";
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ ZipArchive is a simple utility class for zipping and unzipping files on iOS, mac
|
||||
|
||||
## Installation and Setup
|
||||
|
||||
*The main release branch is configured to support Objective C and Swift 3+. There is a 'swift23' branch which is a tied to a older 1.x release and will not be upgraded.*
|
||||
*The main release branch is configured to support Objective C and Swift 3+.*
|
||||
|
||||
SSZipArchive works on Xcode 7-9 and above, iOS 8-11 and above.
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
//
|
||||
// SSZipArchive+Swift.swift
|
||||
// ZipArchive
|
||||
//
|
||||
// Created by William Dunay on 7/6/16.
|
||||
// Copyright © 2016 smumryak. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
extension SSZipArchive {
|
||||
|
||||
static func unzipFileAtPath(_ path: String, toDestination destination: String, overwrite: Bool, password: String?, delegate: SSZipArchiveDelegate?) throws -> Bool {
|
||||
|
||||
var success = false
|
||||
var error: NSError?
|
||||
|
||||
success = __unzipFile(atPath: path, toDestination: destination, overwrite: overwrite, password: password, error: &error, delegate: delegate)
|
||||
if let throwableError = error {
|
||||
throw throwableError
|
||||
}
|
||||
|
||||
return success
|
||||
}
|
||||
}
|
||||
@@ -295,9 +295,10 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo);
|
||||
[delegate zipArchiveProgressEvent:currentPosition total:fileSize];
|
||||
}
|
||||
|
||||
NSInteger currentFileNumber = 0;
|
||||
NSInteger currentFileNumber = -1;
|
||||
NSError *unzippingError;
|
||||
do {
|
||||
currentFileNumber++;
|
||||
if (ret == UNZ_END_OF_LIST_OF_FILE)
|
||||
break;
|
||||
@autoreleasepool {
|
||||
@@ -331,7 +332,8 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo);
|
||||
if ([delegate respondsToSelector:@selector(zipArchiveShouldUnzipFileAtIndex:totalFiles:archivePath:fileInfo:)]) {
|
||||
if (![delegate zipArchiveShouldUnzipFileAtIndex:currentFileNumber
|
||||
totalFiles:(NSInteger)globalInfo.number_entry
|
||||
archivePath:path fileInfo:fileInfo]) {
|
||||
archivePath:path
|
||||
fileInfo:fileInfo]) {
|
||||
success = NO;
|
||||
canceled = YES;
|
||||
break;
|
||||
@@ -358,6 +360,12 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo);
|
||||
BOOL fileIsSymbolicLink = _fileIsSymbolicLink(&fileInfo);
|
||||
|
||||
NSString * strPath = [SSZipArchive _filenameStringWithCString:filename size:fileInfo.size_filename];
|
||||
if ([strPath hasPrefix:@"__MACOSX/"]) {
|
||||
// ignoring resource forks: https://superuser.com/questions/104500/what-is-macosx-folder
|
||||
unzCloseCurrentFile(zip);
|
||||
ret = unzGoToNextFile(zip);
|
||||
continue;
|
||||
}
|
||||
if (!strPath.length) {
|
||||
// if filename data is unsalvageable, we default to currentFileNumber
|
||||
strPath = @(currentFileNumber).stringValue;
|
||||
@@ -434,24 +442,23 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo);
|
||||
}
|
||||
|
||||
if (fp) {
|
||||
if (nestedZipLevel && [fullPath.pathExtension.lowercaseString isEqualToString:@"zip"]) {
|
||||
if ([self unzipFileAtPath:fullPath
|
||||
toDestination:fullPath.stringByDeletingLastPathComponent
|
||||
preserveAttributes:preserveAttributes
|
||||
overwrite:overwrite
|
||||
nestedZipLevel:nestedZipLevel - 1
|
||||
password:password
|
||||
error:nil
|
||||
delegate:nil
|
||||
progressHandler:nil
|
||||
completionHandler:nil]) {
|
||||
[[NSFileManager defaultManager] removeItemAtPath:fullPath error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
if (preserveAttributes) {
|
||||
if (nestedZipLevel
|
||||
&& [fullPath.pathExtension.lowercaseString isEqualToString:@"zip"]
|
||||
&& [self unzipFileAtPath:fullPath
|
||||
toDestination:fullPath.stringByDeletingLastPathComponent
|
||||
preserveAttributes:preserveAttributes
|
||||
overwrite:overwrite
|
||||
nestedZipLevel:nestedZipLevel - 1
|
||||
password:password
|
||||
error:nil
|
||||
delegate:nil
|
||||
progressHandler:nil
|
||||
completionHandler:nil]) {
|
||||
[directoriesModificationDates removeLastObject];
|
||||
[[NSFileManager defaultManager] removeItemAtPath:fullPath error:nil];
|
||||
} else if (preserveAttributes) {
|
||||
|
||||
// Set the original datetime property
|
||||
if (fileInfo.dos_date != 0) {
|
||||
@@ -556,7 +563,7 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo);
|
||||
|
||||
crc_ret = unzCloseCurrentFile(zip);
|
||||
if (crc_ret == UNZ_CRCERROR) {
|
||||
//CRC ERROR
|
||||
// CRC ERROR
|
||||
success = NO;
|
||||
break;
|
||||
}
|
||||
@@ -571,7 +578,6 @@ BOOL _fileIsSymbolicLink(const unz_file_info *fileInfo);
|
||||
archivePath:path unzippedFilePath: fullPath];
|
||||
}
|
||||
|
||||
currentFileNumber++;
|
||||
if (progressHandler)
|
||||
{
|
||||
progressHandler(strPath, fileInfo, currentFileNumber, globalInfo.number_entry);
|
||||
|
||||
@@ -1297,9 +1297,12 @@ extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, uint32_t len)
|
||||
s->pfile_in_zip_read->stream.next_out = (uint8_t*)buf;
|
||||
s->pfile_in_zip_read->stream.avail_out = (uint16_t)len;
|
||||
|
||||
if (len > s->pfile_in_zip_read->rest_read_compressed + s->pfile_in_zip_read->stream.avail_in)
|
||||
s->pfile_in_zip_read->stream.avail_out = (uint16_t)s->pfile_in_zip_read->rest_read_compressed +
|
||||
s->pfile_in_zip_read->stream.avail_in;
|
||||
if ((s->pfile_in_zip_read->compression_method == 0) || (s->pfile_in_zip_read->raw))
|
||||
{
|
||||
if (len > s->pfile_in_zip_read->rest_read_compressed + s->pfile_in_zip_read->stream.avail_in)
|
||||
s->pfile_in_zip_read->stream.avail_out = (uint16_t)s->pfile_in_zip_read->rest_read_compressed +
|
||||
s->pfile_in_zip_read->stream.avail_in;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
@@ -70,11 +70,17 @@ class ViewController: UIViewController {
|
||||
}
|
||||
|
||||
let password = passwordField.text
|
||||
let success: Void? = try? SSZipArchive.unzipFile(atPath: zipPath,
|
||||
toDestination: unzipPath,
|
||||
overwrite: true,
|
||||
password: password?.isEmpty == false ? password : nil)
|
||||
if success != nil {
|
||||
let success: Bool = SSZipArchive.unzipFile(atPath: zipPath,
|
||||
toDestination: unzipPath,
|
||||
preserveAttributes: true,
|
||||
overwrite: true,
|
||||
nestedZipLevel: 1,
|
||||
password: password?.isEmpty == false ? password : nil,
|
||||
error: nil,
|
||||
delegate: nil,
|
||||
progressHandler: nil,
|
||||
completionHandler: nil)
|
||||
if success != false {
|
||||
print("Success unzip")
|
||||
} else {
|
||||
print("No success unzip")
|
||||
|
||||
@@ -101,7 +101,6 @@
|
||||
37952C551F63B7A000DD6677 /* pwd2key.h in Headers */ = {isa = PBXBuildFile; fileRef = 373913F81F0009310094DB3B /* pwd2key.h */; };
|
||||
37952C561F63B7A000DD6677 /* sha1.c in Sources */ = {isa = PBXBuildFile; fileRef = 373913F91F0009310094DB3B /* sha1.c */; };
|
||||
37952C571F63B7A000DD6677 /* sha1.h in Headers */ = {isa = PBXBuildFile; fileRef = 373913FA1F0009310094DB3B /* sha1.h */; };
|
||||
37952C581F63B8C400DD6677 /* SSZipArchive+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87ACF3E91D2DAFAD00ED2F7E /* SSZipArchive+Swift.swift */; };
|
||||
37952C661F63BBBB00DD6677 /* crypt.c in Sources */ = {isa = PBXBuildFile; fileRef = 373913FC1F0009320094DB3B /* crypt.c */; };
|
||||
37952C671F63BBBB00DD6677 /* ioapi_buf.c in Sources */ = {isa = PBXBuildFile; fileRef = 373913E41F0009310094DB3B /* ioapi_buf.c */; };
|
||||
37952C681F63BBBB00DD6677 /* ioapi_buf.h in Headers */ = {isa = PBXBuildFile; fileRef = 373913E51F0009310094DB3B /* ioapi_buf.h */; };
|
||||
@@ -138,12 +137,10 @@
|
||||
37952C871F63BBC000DD6677 /* sha1.h in Headers */ = {isa = PBXBuildFile; fileRef = 373913FA1F0009310094DB3B /* sha1.h */; };
|
||||
37952C881F63BBD500DD6677 /* SSZipArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = B423AE481C0DF7950004A2F1 /* SSZipArchive.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
37952C891F63BBDA00DD6677 /* SSZipArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = B423AE491C0DF7950004A2F1 /* SSZipArchive.m */; };
|
||||
37952C8A1F63BBE100DD6677 /* SSZipArchive+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87ACF3E91D2DAFAD00ED2F7E /* SSZipArchive+Swift.swift */; };
|
||||
37952C8B1F63BBE400DD6677 /* ZipArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = B423AE4A1C0DF7950004A2F1 /* ZipArchive.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
37952C8C1F63BBED00DD6677 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B423AE6E1C0DF83F0004A2F1 /* libz.tbd */; };
|
||||
37952C8D1F63BBF300DD6677 /* SSZipCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 389869341D5BC30100F18782 /* SSZipCommon.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
389869351D5BC30100F18782 /* SSZipCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 389869341D5BC30100F18782 /* SSZipCommon.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
87ACF3EA1D2DAFAD00ED2F7E /* SSZipArchive+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87ACF3E91D2DAFAD00ED2F7E /* SSZipArchive+Swift.swift */; };
|
||||
AFF75A2D1C3727F000F450AC /* ZipArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = B423AE4A1C0DF7950004A2F1 /* ZipArchive.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
AFF75A2E1C37280200F450AC /* SSZipArchive.h in Headers */ = {isa = PBXBuildFile; fileRef = B423AE481C0DF7950004A2F1 /* SSZipArchive.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
AFF75A2F1C37280200F450AC /* SSZipArchive.m in Sources */ = {isa = PBXBuildFile; fileRef = B423AE491C0DF7950004A2F1 /* SSZipArchive.m */; };
|
||||
@@ -199,7 +196,6 @@
|
||||
37952C261F63B50D00DD6677 /* ZipArchive.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZipArchive.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
37952C5E1F63BB7100DD6677 /* ZipArchive.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZipArchive.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
389869341D5BC30100F18782 /* SSZipCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSZipCommon.h; sourceTree = "<group>"; };
|
||||
87ACF3E91D2DAFAD00ED2F7E /* SSZipArchive+Swift.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "SSZipArchive+Swift.swift"; sourceTree = "<group>"; };
|
||||
AFF75A241C37279600F450AC /* ZipArchive.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZipArchive.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B423AE1A1C0DF76A0004A2F1 /* ZipArchive.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZipArchive.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B423AE3D1C0DF7950004A2F1 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
@@ -307,7 +303,6 @@
|
||||
B423AE3E1C0DF7950004A2F1 /* minizip */,
|
||||
B423AE481C0DF7950004A2F1 /* SSZipArchive.h */,
|
||||
B423AE491C0DF7950004A2F1 /* SSZipArchive.m */,
|
||||
87ACF3E91D2DAFAD00ED2F7E /* SSZipArchive+Swift.swift */,
|
||||
B423AE4A1C0DF7950004A2F1 /* ZipArchive.h */,
|
||||
);
|
||||
path = SSZipArchive;
|
||||
@@ -608,7 +603,6 @@
|
||||
files = (
|
||||
37952C541F63B7A000DD6677 /* pwd2key.c in Sources */,
|
||||
37952C521F63B7A000DD6677 /* prng.c in Sources */,
|
||||
37952C581F63B8C400DD6677 /* SSZipArchive+Swift.swift in Sources */,
|
||||
37952C401F63B78A00DD6677 /* ioapi_mem.c in Sources */,
|
||||
37952C561F63B7A000DD6677 /* sha1.c in Sources */,
|
||||
37952C4A1F63B7A000DD6677 /* aestab.c in Sources */,
|
||||
@@ -633,7 +627,6 @@
|
||||
files = (
|
||||
37952C801F63BBC000DD6677 /* hmac.c in Sources */,
|
||||
37952C841F63BBC000DD6677 /* pwd2key.c in Sources */,
|
||||
37952C8A1F63BBE100DD6677 /* SSZipArchive+Swift.swift in Sources */,
|
||||
37952C7E1F63BBC000DD6677 /* fileenc.c in Sources */,
|
||||
37952C891F63BBDA00DD6677 /* SSZipArchive.m in Sources */,
|
||||
37952C7A1F63BBC000DD6677 /* aestab.c in Sources */,
|
||||
@@ -682,7 +675,6 @@
|
||||
files = (
|
||||
3739141D1F0009FF0094DB3B /* hmac.c in Sources */,
|
||||
3739140E1F0009E50094DB3B /* aes_ni.c in Sources */,
|
||||
87ACF3EA1D2DAFAD00ED2F7E /* SSZipArchive+Swift.swift in Sources */,
|
||||
373914211F0009FF0094DB3B /* pwd2key.c in Sources */,
|
||||
373914171F0009FF0094DB3B /* aestab.c in Sources */,
|
||||
373914021F0009C80094DB3B /* minishared.c in Sources */,
|
||||
|
||||
Reference in New Issue
Block a user