Kōtuku
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Config
    • Core
    • Display
    • Document
    • Font
    • HTTP
    • Network
    • Regex
    • SVG
    • Tiri
    • Vector
    • XML
    • XQuery
    • XRandR
      • Audio
      • MP3
      • Sound
      • File
      • MetaClass
      • Module
      • StorageDevice
      • Task
      • Thread
      • Time
      • Compression
      • CompressedStream
      • Config
      • LZMAStream
      • Script
      • Tiri
      • XML
      • XQuery
      • Controller
      • BlurFX
      • ColourFX
      • CompositeFX
      • ConvolveFX
      • DisplacementFX
      • FilterEffect
      • FloodFX
      • ImageFX
      • LightingFX
      • MergeFX
      • MorphologyFX
      • OffsetFX
      • RemapFX
      • SourceFX
      • TurbulenceFX
      • WaveFunctionFX
      • Scintilla
      • Bitmap
      • Clipboard
      • Display
      • Document
      • Font
      • Image
      • Pointer
      • Surface
      • SVG
      • ClientSocket
      • HTTP
      • NetClient
      • NetLookup
      • NetServer
      • NetSocket
      • Proxy
      • Gradient
      • GradientConic
      • GradientContour
      • GradientDiamond
      • GradientDiffusion
      • GradientDistal
      • GradientGouraud
      • GradientLinear
      • GradientMesh
      • GradientRadial
      • GradientVoronoi
      • Vector
      • VectorClip
      • VectorColour
      • VectorEllipse
      • VectorFilter
      • VectorGradient
      • VectorGroup
      • VectorImage
      • VectorPath
      • VectorPattern
      • VectorPolygon
      • VectorRectangle
      • VectorScene
      • VectorShape
      • VectorSpiral
      • VectorText
      • VectorTransition
      • VectorViewport
      • VectorWave
      • Linux Builds
      • Windows Builds
      • Customising Your Build
      • Kōtuku Objects
      • Kōtuku In Depth
      • Kōtuku Design Patterns
      • Coding With AI
      • Regex Manual
      • XML Comparisons
      • Tiri Reference Manual
      • Config API
      • Defer Syntax
      • GUI API
      • HTTP Server API
      • I/O API
      • JSON API
      • OAuth API
      • Options API
      • Proxy Server API
      • Tempus API
      • URL API
      • VFX API
      • Widgets
      • RIPL Reference Manual
      • Origo
      • Flute / Unit Testing
      • Tuku
      • Embedded Document Format
      • TDL Reference Manual
      • TDL Tools
      • Action Reference Manual
      • System Error Codes

LZMAStream Class

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.

Structure

The LZMAStream class consists of the following fields:

Access
NameTypeComment
 SizeINT64The 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.

Actions

The following actions are currently supported:

ReadDecompress data from the input stream and write it to the supplied buffer.
ERR acRead(*Object, std::span<int8_t> Buffer, INT *Result)
ParameterDescription
BufferA mutable buffer that will receive the data.
ResultThe Read action will write this parameter with the total number of bytes read into the Buffer.

The Read() action decodes the raw LZMA1 stream supplied via CompressedStream⇒Input, writing up to Length decompressed bytes into the caller's buffer. Decoding is bounded by Size; once that many bytes have been produced, subsequent reads return zero bytes. Truncated input, a premature end marker or output that would exceed Size are reported as ERR::Decompression.

ResetReset 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.

SeekFor use in decompressing streams only. Seeks to a position within the stream.
ERR acSeek(*Object, DOUBLE Offset, INT Position)
ParameterDescription
OffsetThe desired offset to seek to, relative to the Position parameter.
PositionThe position that defines the starting point for Offset.
WriteNot supported. LZMAStream is decode-only.
ERR acWrite(*Object, std::span<const int8_t> Buffer, INT *Result)
ParameterDescription
BufferA buffer containing the data that will be written to the object.
ResultThis parameter with be updated with the total number of bytes written from the Buffer.
LZMAStream class documentation © Paul Manias © 2024-2026