Decompresses raw LZMA1 data streams.
The LZMAStream class extends CompressedStream with support for decoding raw LZMA1 streams. It is provided by the separate LZMA module so that the Core remains free of an LZMA dependency; only builds that require LZMA pull the module in.
LZMAStream is decode-only and is instantiated directly rather than being selected through a CompressedStream⇒Format option on the base class. To decompress a stream, set the CompressedStream⇒Input field with a source object that supports the Read() action (such as a File) and set the required Size field to the exact number of decompressed bytes expected. Repeatedly reading from the LZMAStream then yields the decompressed data:
lz = obj.new('lzmastream', { input=file, size=body_size })
err, len = lz.acRead(buffer)
The class decodes a raw LZMA1 stream consisting of a 5-byte properties header followed by the compressed data. It does not parse the .lzma/.alone 13-byte header or the .xz container; callers are responsible for any outer framing. Because raw LZMA1 streams may lack a reliable end marker, Size is used to bound the output: decoding completes when exactly that many bytes have been produced, and an end marker or exhausted input encountered before that point is reported as a decompression error.
The inherited CompressedStream⇒Format field has no meaning for this class and is ignored.
The LZMAStream class consists of the following fields:
Access | Name | Type | Comment |
|---|---|---|---|
| Size | INT64 | The exact number of bytes expected from the decompressed stream. | |
This field is required prior to initialisation. Raw LZMA1 streams may not carry a reliable end marker, so the value is used to bound decoding: the stream completes when exactly this many bytes have been produced, and an end marker or exhausted input encountered beforehand is reported as a decompression error. | |||
The following actions are currently supported:
| Read | Decompress data from the input stream and write it to the supplied buffer. | |||||||
|---|---|---|---|---|---|---|---|---|
ERR acRead(*Object, std::span<int8_t> Buffer, INT *Result)
The Read() action decodes the raw LZMA1 stream supplied via CompressedStream⇒Input, writing up to | ||||||||
| Reset | Reset the state of the stream. | |||||||
ERR acReset(*Object) Resetting an LZMAStream returns it to the same state as when first initialised. This does not affect the state of the object referenced via CompressedStream⇒Input, so the client may need to reset or re-seek that object separately. | ||||||||
| Seek | For use in decompressing streams only. Seeks to a position within the stream. | |||||||
ERR acSeek(*Object, DOUBLE Offset, INT Position)
| ||||||||
| Write | Not supported. LZMAStream is decode-only. | |||||||
ERR acWrite(*Object, std::span<const int8_t> Buffer, INT *Result)
| ||||||||