Support unavailable data in SevenZipEntry (when no substreamInfo is found)

This commit is contained in:
Timofey Solomko
2017-07-30 15:52:28 +03:00
parent f0bdff081a
commit 3503bcbb89
2 changed files with 12 additions and 5 deletions
+11 -5
View File
@@ -23,17 +23,23 @@ public class SevenZipEntry: ContainerEntry {
public var entryAttributes: [FileAttributeKey: Any]
private let dataObject: Data
public let dataIsAvailable: Bool
init(_ entryInfo: SevenZipEntryInfo, _ data: Data) {
// TODO: Make data decoding here?
private let dataObject: Data?
init(_ entryInfo: SevenZipEntryInfo, _ data: Data?) {
self.info = entryInfo
self.dataObject = data
self.dataIsAvailable = data != nil
self.entryAttributes = [:]
}
public func data() -> Data {
return dataObject
public func data() throws -> Data {
if let data = dataObject {
return data
} else {
throw SevenZipError.dataIsUnavailable
}
}
}
+1
View File
@@ -38,4 +38,5 @@ public enum SevenZipError: Error {
case noStreamFound
case noPackInfoFound
case streamOverread
case dataIsUnavailable
}