Skip to content

Commit 6e16483

Browse files
authored
Merge pull request marmelroy#89 from piemonte/master
unzip file handler support
2 parents 4a15a78 + 3e33d0d commit 6e16483

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Zip/Zip.swift

+6-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public class Zip {
8282
- notes: Supports implicit progress composition
8383
*/
8484

85-
public class func unzipFile(_ zipFilePath: URL, destination: URL, overwrite: Bool, password: String?, progress: ((_ progress: Double) -> ())?) throws {
85+
public class func unzipFile(_ zipFilePath: URL, destination: URL, overwrite: Bool, password: String?, progress: ((_ progress: Double) -> ())? = nil, fileOutputHandler: ((_ unzippedFile: URL) -> Void)? = nil) throws {
8686

8787
// File manager
8888
let fileManager = FileManager.default
@@ -218,6 +218,11 @@ public class Zip {
218218
progressHandler((currentPosition/totalSize))
219219
}
220220

221+
if let fileHandler = fileOutputHandler,
222+
let fileUrl = URL(string: fullPath) {
223+
fileHandler(fileUrl)
224+
}
225+
221226
progressTracker.completedUnitCount = Int64(currentPosition)
222227

223228
} while (ret == UNZ_OK && ret != UNZ_END_OF_LIST_OF_FILE)

0 commit comments

Comments
 (0)