mirror of
https://github.com/tsolomko/SWCompression.git
synced 2026-06-23 14:56:41 +00:00
Use new LZMA decoder in LZMA itself
This commit is contained in:
+15
-3
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user