diff --git a/Zip/Zip.swift b/Zip/Zip.swift index a74d325d5ca330acf0d0346fb4b4b8e1f8bc8e45..b2864b65e0741839c65e73a025913c4010d85057 100644 --- a/Zip/Zip.swift +++ b/Zip/Zip.swift @@ -134,7 +134,8 @@ public class Zip { try fileManager.createDirectoryAtPath(fullPath, withIntermediateDirectories: true, attributes: directoryAttributes) } else { - try fileManager.createDirectoryAtPath(destinationPath, withIntermediateDirectories: true, attributes: directoryAttributes) + let parentDirectory = (fullPath as NSString).stringByDeletingLastPathComponent + try fileManager.createDirectoryAtPath(parentDirectory, withIntermediateDirectories: true, attributes: directoryAttributes) } } catch {} if fileManager.fileExistsAtPath(fullPath) && !isDirectory && !overwrite { diff --git a/ZipTests/ZipTests.swift b/ZipTests/ZipTests.swift index 387abda527f5c94734fa0c11cfba365bed013099..53fe334f054bcdb0d894bd427afc0550c2152234 100644 --- a/ZipTests/ZipTests.swift +++ b/ZipTests/ZipTests.swift @@ -147,6 +147,23 @@ class ZipTests: XCTestCase { XCTFail() } } + + func testQuickUnzipSubDir() { + do { + let bookURL = NSBundle(forClass: ZipTests.self).URLForResource("bb8", withExtension: "zip")! + let unzipDestination = try Zip.quickUnzipFile(bookURL) + let fileManager = NSFileManager.defaultManager() + + let subDir = unzipDestination.URLByAppendingPathComponent("subDir") + let imageURL = subDir.URLByAppendingPathComponent("r2W9yu9").URLByAppendingPathExtension("gif") + + XCTAssertTrue(fileManager.fileExistsAtPath(unzipDestination.path!)) + XCTAssertTrue(fileManager.fileExistsAtPath(subDir.path!)) + XCTAssertTrue(fileManager.fileExistsAtPath(imageURL.path!)) + } catch { + XCTFail() + } + } } diff --git a/ZipTests/bb8.zip b/ZipTests/bb8.zip index 4d903fe1c5323303c51968bed6ab4b38de1bd912..514266d193061fd851c447a37de608daef3136fa 100644 Binary files a/ZipTests/bb8.zip and b/ZipTests/bb8.zip differ