Commit 3051d09d authored by Jake's avatar Jake

Fix unzipping files within sub directory

parent e2615167
...@@ -134,7 +134,8 @@ public class Zip { ...@@ -134,7 +134,8 @@ public class Zip {
try fileManager.createDirectoryAtPath(fullPath, withIntermediateDirectories: true, attributes: directoryAttributes) try fileManager.createDirectoryAtPath(fullPath, withIntermediateDirectories: true, attributes: directoryAttributes)
} }
else { else {
try fileManager.createDirectoryAtPath(destinationPath, withIntermediateDirectories: true, attributes: directoryAttributes) let parentDirectory = (fullPath as NSString).stringByDeletingLastPathComponent
try fileManager.createDirectoryAtPath(parentDirectory, withIntermediateDirectories: true, attributes: directoryAttributes)
} }
} catch {} } catch {}
if fileManager.fileExistsAtPath(fullPath) && !isDirectory && !overwrite { if fileManager.fileExistsAtPath(fullPath) && !isDirectory && !overwrite {
......
...@@ -147,6 +147,23 @@ class ZipTests: XCTestCase { ...@@ -147,6 +147,23 @@ class ZipTests: XCTestCase {
XCTFail() 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()
}
}
} }
No preview for this file type
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment