From 3e33d0df7d3931b96a9c6cbdadda1f92cefddd30 Mon Sep 17 00:00:00 2001 From: patrick piemonte Date: Tue, 13 Jun 2017 13:57:43 -0700 Subject: [PATCH] provide a file URL when unzipped https://github.com/marmelroy/Zip/issues/78 --- Zip/Zip.swift | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Zip/Zip.swift b/Zip/Zip.swift index 7729643..a2eb115 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) -> ())? = nil) 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) -- 2.26.2