diff --git a/Zip/Zip.swift b/Zip/Zip.swift index 80722dc709545cd9bd3fb1e45c2c189cc1261874..a2eb11593097dc63e69929c4e1d913d8a32605b2 100644 --- a/Zip/Zip.swift +++ b/Zip/Zip.swift @@ -82,7 +82,7 @@ public class Zip { - 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 let fileManager = FileManager.default @@ -218,6 +218,11 @@ public class Zip { progressHandler((currentPosition/totalSize)) } + if let fileHandler = fileOutputHandler, + let fileUrl = URL(string: fullPath) { + fileHandler(fileUrl) + } + progressTracker.completedUnitCount = Int64(currentPosition) } while (ret == UNZ_OK && ret != UNZ_END_OF_LIST_OF_FILE)