diff --git a/Zip.xcodeproj/project.pbxproj b/Zip.xcodeproj/project.pbxproj index 387784d9b44bc8056e8068b52dc664df480072d4..4e4adc68bd78b6383daf6cb939e7df754d6d3f76 100644 --- a/Zip.xcodeproj/project.pbxproj +++ b/Zip.xcodeproj/project.pbxproj @@ -37,6 +37,9 @@ 3430F6351C45C851007473A6 /* zip.c in Sources */ = {isa = PBXBuildFile; fileRef = 3430F62B1C45C851007473A6 /* zip.c */; }; 3430F6361C45C851007473A6 /* zip.h in Headers */ = {isa = PBXBuildFile; fileRef = 3430F62C1C45C851007473A6 /* zip.h */; }; 3443A3F61C4AB8A3004AD173 /* QuickZip.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3443A3F51C4AB8A3004AD173 /* QuickZip.swift */; }; + 3443A3F91C4AD169004AD173 /* kYkLkPf.gif in Resources */ = {isa = PBXBuildFile; fileRef = 3443A3F81C4AD169004AD173 /* kYkLkPf.gif */; }; + 3443A3FB1C4AD16F004AD173 /* 3crBXeO.gif in Resources */ = {isa = PBXBuildFile; fileRef = 3443A3FA1C4AD16F004AD173 /* 3crBXeO.gif */; }; + 3443A3FD1C4AD199004AD173 /* bb8.zip in Resources */ = {isa = PBXBuildFile; fileRef = 3443A3FC1C4AD199004AD173 /* bb8.zip */; }; 347E3A781C1DFFB500A11FD3 /* Zip.h in Headers */ = {isa = PBXBuildFile; fileRef = 347E3A771C1DFFB500A11FD3 /* Zip.h */; settings = {ATTRIBUTES = (Public, ); }; }; 347E3A7F1C1DFFB500A11FD3 /* Zip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 347E3A741C1DFFB500A11FD3 /* Zip.framework */; }; 347E3A841C1DFFB500A11FD3 /* ZipTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 347E3A831C1DFFB500A11FD3 /* ZipTests.swift */; }; @@ -85,6 +88,9 @@ 3430F62C1C45C851007473A6 /* zip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zip.h; sourceTree = ""; }; 3433BFCD1C48D3EC006DF000 /* module.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = module.modulemap; sourceTree = ""; }; 3443A3F51C4AB8A3004AD173 /* QuickZip.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuickZip.swift; sourceTree = ""; }; + 3443A3F81C4AD169004AD173 /* kYkLkPf.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = kYkLkPf.gif; sourceTree = ""; }; + 3443A3FA1C4AD16F004AD173 /* 3crBXeO.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = 3crBXeO.gif; sourceTree = ""; }; + 3443A3FC1C4AD199004AD173 /* bb8.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = bb8.zip; sourceTree = ""; }; 347E3A741C1DFFB500A11FD3 /* Zip.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Zip.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 347E3A771C1DFFB500A11FD3 /* Zip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Zip.h; sourceTree = ""; }; 347E3A791C1DFFB500A11FD3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -192,6 +198,9 @@ 347E3A821C1DFFB500A11FD3 /* ZipTests */ = { isa = PBXGroup; children = ( + 3443A3FA1C4AD16F004AD173 /* 3crBXeO.gif */, + 3443A3F81C4AD169004AD173 /* kYkLkPf.gif */, + 3443A3FC1C4AD199004AD173 /* bb8.zip */, 347E3A831C1DFFB500A11FD3 /* ZipTests.swift */, 347E3A851C1DFFB500A11FD3 /* Info.plist */, ); @@ -312,6 +321,9 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 3443A3FD1C4AD199004AD173 /* bb8.zip in Resources */, + 3443A3F91C4AD169004AD173 /* kYkLkPf.gif in Resources */, + 3443A3FB1C4AD16F004AD173 /* 3crBXeO.gif in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Zip.xcodeproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint b/Zip.xcodeproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint new file mode 100644 index 0000000000000000000000000000000000000000..0b4f0601b4ab6655a53945f681d7c7211fc635a6 --- /dev/null +++ b/Zip.xcodeproj/project.xcworkspace/xcshareddata/Zip.xcscmblueprint @@ -0,0 +1,30 @@ +{ + "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4", + "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { + + }, + "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { + "8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD" : 0, + "3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" : 0 + }, + "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "F3707899-72AE-49DA-9BDD-5CB0B64CF03A", + "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { + "8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD" : "Zip\/Zip\/minizip\/", + "3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" : "Zip\/" + }, + "DVTSourceControlWorkspaceBlueprintNameKey" : "Zip", + "DVTSourceControlWorkspaceBlueprintVersion" : 204, + "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Zip.xcodeproj", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/marmelroy\/Zip.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3DD768C8AB2D6A2647C9EF99992D3CC5820E77C4" + }, + { + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/marmelroy\/minizip.git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", + "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "8DA5B175D3FDB92A3B3CCBD4109A734F1316A3DD" + } + ] +} \ No newline at end of file diff --git a/Zip/QuickZip.swift b/Zip/QuickZip.swift index fd42aebf12ab4259b4a9adcbec26f35fa7762049..d75d7ddf7230fcd4aef994b637e7b43e3c2ec1e6 100644 --- a/Zip/QuickZip.swift +++ b/Zip/QuickZip.swift @@ -39,7 +39,7 @@ extension Zip { guard let fileExtension = path.pathExtension, let fileName = path.lastPathComponent else { throw ZipError.UnzipFail } - let directoryName = fileName.stringByReplacingOccurrencesOfString(fileExtension, withString: "") + let directoryName = fileName.stringByReplacingOccurrencesOfString(".\(fileExtension)", withString: "") let destinationUrl = documentsUrl.URLByAppendingPathComponent(directoryName, isDirectory: true) try self.unzipFile(path, destination: destinationUrl, overwrite: true, password: nil, progress: progress) return destinationUrl diff --git a/Zip/Zip.swift b/Zip/Zip.swift index 5ff9a114c7670d63fe7fe88f1748e37c8bf5b2ee..931aa3a83ee7308de4368d5ffb7231a79a9592eb 100644 --- a/Zip/Zip.swift +++ b/Zip/Zip.swift @@ -57,7 +57,7 @@ public class Zip { public func unzipFile(path: NSURL, destination: NSURL, overwrite: Bool, password: String?, progress: ((progress: Double) -> ())?) throws { // Check whether a zip file exists at path. let fileManager = NSFileManager.defaultManager() - if fileManager.fileExistsAtPath(path.absoluteString) == false || path.pathExtension != ".zip" { + if fileManager.fileExistsAtPath(path.path!) == false || path.pathExtension != "zip" { throw ZipError.FileNotFound } // Unzip set up @@ -66,9 +66,9 @@ public class Zip { let bufferSize: UInt32 = 4096 var buffer = Array(count: Int(bufferSize), repeatedValue: 0) // Begin unzipping - let zip = unzOpen64(path.absoluteString) + let zip = unzOpen64(path.path!) - let fileAttributes = try fileManager.attributesOfItemAtPath(path.absoluteString) + let fileAttributes = try fileManager.attributesOfItemAtPath(path.path!) let totalSize = fileAttributes[NSFileSize] as? Double var currentPosition: Double = 0.0 if unzGoToFirstFile(zip) != UNZ_OK { diff --git a/ZipTests/3crBXeO.gif b/ZipTests/3crBXeO.gif new file mode 100644 index 0000000000000000000000000000000000000000..0c7d073aa1cb9959b88f152543e470f248553694 Binary files /dev/null and b/ZipTests/3crBXeO.gif differ diff --git a/ZipTests/ZipTests.swift b/ZipTests/ZipTests.swift index f3a1876aff2b7943e3b533e41fcfa2831ac05b15..8c49287bdcb3d3e348567d26d9c7543f4500b185 100644 --- a/ZipTests/ZipTests.swift +++ b/ZipTests/ZipTests.swift @@ -13,24 +13,24 @@ class ZipTests: XCTestCase { override func setUp() { super.setUp() - // Put setup code here. This method is called before the invocation of each test method in the class. } override func tearDown() { - // Put teardown code here. This method is called after the invocation of each test method in the class. super.tearDown() } - func testExample() { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. - } - - func testPerformanceExample() { - // This is an example of a performance test case. - self.measureBlock { - // Put the code you want to measure the time of here. + func testQuickUnzip() { + do { + let fileAbsoluteURL = NSBundle(forClass: ZipTests.self).URLForResource("bb8", withExtension: "zip")! + let destinationURL = try Zip().quickUnzipFile(fileAbsoluteURL) + let fileManager = NSFileManager.defaultManager() + XCTAssertTrue(fileManager.fileExistsAtPath(destinationURL.path!)) + } + catch { + XCTFail() } + } + } diff --git a/ZipTests/bb8.zip b/ZipTests/bb8.zip new file mode 100644 index 0000000000000000000000000000000000000000..4d903fe1c5323303c51968bed6ab4b38de1bd912 Binary files /dev/null and b/ZipTests/bb8.zip differ diff --git a/ZipTests/kYkLkPf.gif b/ZipTests/kYkLkPf.gif new file mode 100644 index 0000000000000000000000000000000000000000..da184d53b7159a979d8838eea1c14a3d1f0cfff1 Binary files /dev/null and b/ZipTests/kYkLkPf.gif differ