Zip archive: Handle files within folders inside the zip
This commit is contained in:
parent
911e7156b3
commit
eb122f87e2
|
@ -61,10 +61,10 @@ class ZipArchive {
|
||||||
throw ZipArchiveError.badArchive
|
throw ZipArchiveError.badArchive
|
||||||
}
|
}
|
||||||
|
|
||||||
let fileName = String(cString: fileNameBuffer)
|
if let fileURL = URL(string: String(cString: fileNameBuffer)),
|
||||||
let fileExtension = URL(string: fileName)?.pathExtension ?? ""
|
!fileURL.hasDirectoryPath,
|
||||||
|
requiredFileExtensions.contains(fileURL.pathExtension) {
|
||||||
|
|
||||||
if (requiredFileExtensions.contains(fileExtension)) {
|
|
||||||
var unzippedData = Data()
|
var unzippedData = Data()
|
||||||
var bytesRead: Int32 = 0
|
var bytesRead: Int32 = 0
|
||||||
repeat {
|
repeat {
|
||||||
|
@ -77,7 +77,7 @@ class ZipArchive {
|
||||||
unzippedData.append(dataRead)
|
unzippedData.append(dataRead)
|
||||||
}
|
}
|
||||||
} while (bytesRead > 0)
|
} while (bytesRead > 0)
|
||||||
results.append((fileName: fileName, contents: unzippedData))
|
results.append((fileName: fileURL.lastPathComponent, contents: unzippedData))
|
||||||
}
|
}
|
||||||
|
|
||||||
guard (unzCloseCurrentFile(zipFile) == UNZ_OK) else {
|
guard (unzCloseCurrentFile(zipFile) == UNZ_OK) else {
|
||||||
|
|
Loading…
Reference in New Issue