mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
[LZMA] Add LZMAProperties initializer which reads lzma encoded properties from bytereader
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user