Use new LZMA decoder in LZMA itself

This commit is contained in:
Timofey Solomko
2017-10-29 12:03:46 +03:00
parent 722805a35d
commit d062ffb0ea
+15 -3
View File
@@ -28,9 +28,21 @@ public class LZMA: DecompressionAlgorithm {
}
static func decompress(_ pointerData: DataWithPointer) throws -> [UInt8] {
let lzmaDecoder = try LZMADecoder(pointerData)
try lzmaDecoder.decodeLZMA()
return lzmaDecoder.out
let decoder = try LZMATempDecoder(pointerData)
try decoder.setProperties(from: pointerData.byte())
decoder.resetStateAndDecoders()
decoder.dictionarySize = pointerData.uint32().toInt()
let uncompressedSize = pointerData.uint64()
if uncompressedSize == UInt64.max {
decoder.uncompressedSize = -1
} else {
decoder.uncompressedSize = Int(truncatingIfNeeded: uncompressedSize)
}
try decoder.decode()
return decoder.out
}
}