Commit 6e16483d authored by Roy Marmelstein's avatar Roy Marmelstein Committed by GitHub

Merge pull request #89 from piemonte/master

unzip file handler support
parents 4a15a786 3e33d0df
...@@ -82,7 +82,7 @@ public class Zip { ...@@ -82,7 +82,7 @@ public class Zip {
- notes: Supports implicit progress composition - notes: Supports implicit progress composition
*/ */
public class func unzipFile(_ zipFilePath: URL, destination: URL, overwrite: Bool, password: String?, progress: ((_ progress: Double) -> ())?) throws { public class func unzipFile(_ zipFilePath: URL, destination: URL, overwrite: Bool, password: String?, progress: ((_ progress: Double) -> ())? = nil, fileOutputHandler: ((_ unzippedFile: URL) -> Void)? = nil) throws {
// File manager // File manager
let fileManager = FileManager.default let fileManager = FileManager.default
...@@ -218,6 +218,11 @@ public class Zip { ...@@ -218,6 +218,11 @@ public class Zip {
progressHandler((currentPosition/totalSize)) progressHandler((currentPosition/totalSize))
} }
if let fileHandler = fileOutputHandler,
let fileUrl = URL(string: fullPath) {
fileHandler(fileUrl)
}
progressTracker.completedUnitCount = Int64(currentPosition) progressTracker.completedUnitCount = Int64(currentPosition)
} while (ret == UNZ_OK && ret != UNZ_END_OF_LIST_OF_FILE) } while (ret == UNZ_OK && ret != UNZ_END_OF_LIST_OF_FILE)
......
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