diff --git a/Sources/LZMA/LZMA.swift b/Sources/LZMA/LZMA.swift index 703de708..4b8da10f 100644 --- a/Sources/LZMA/LZMA.swift +++ b/Sources/LZMA/LZMA.swift @@ -24,7 +24,7 @@ public class LZMA: DecompressionAlgorithm { */ public static func decompress(data: Data) throws -> Data { let byteReader = ByteReader(data: data) - let properties = try LZMAProperties(lzmaByte: byteReader.byte(), byteReader.int(fromBytes: 4)) + let properties = try LZMAProperties(byteReader) let uncompSize = byteReader.int(fromBytes: 8) return try decompress(byteReader, properties, uncompSize) } diff --git a/Sources/LZMA/LZMAProperties.swift b/Sources/LZMA/LZMAProperties.swift index 524cda19..4e00919d 100644 --- a/Sources/LZMA/LZMAProperties.swift +++ b/Sources/LZMA/LZMAProperties.swift @@ -3,6 +3,8 @@ // // See LICENSE for license information +import BitByteData + public struct LZMAProperties { public var lc: Int @@ -43,4 +45,8 @@ public struct LZMAProperties { self.dictionarySize = dictSize } + init(_ byteReader: ByteReader) throws { + try self.init(lzmaByte: byteReader.byte(), byteReader.int(fromBytes: 4)) + } + } diff --git a/Sources/ZIP/ZipContainer.swift b/Sources/ZIP/ZipContainer.swift index 8aae1033..25ad48bd 100644 --- a/Sources/ZIP/ZipContainer.swift +++ b/Sources/ZIP/ZipContainer.swift @@ -89,10 +89,7 @@ public class ZipContainer: Container { case .lzma: #if (!SWCOMPRESSION_POD_ZIP) || (SWCOMPRESSION_POD_ZIP && SWCOMPRESSION_POD_LZMA) byteReader.offset += 4 // Skipping LZMA SDK version and size of properties. - fileData = try LZMA.decompress(byteReader, - LZMAProperties(lzmaByte: byteReader.byte(), - byteReader.int(fromBytes: 4)), - uncompSize.toInt()) + fileData = try LZMA.decompress(byteReader, LZMAProperties(byteReader), uncompSize.toInt()) #else throw ZipError.compressionNotSupported #endif