lzma

package
v0.0.0-...-72c091b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinDictCap = 1 << 12
	MaxDictCap = 1<<32 - 1
)
View Source
const HeaderLen = 6

HeaderLen provides the length of the LZMA file header.

Variables

View Source
var ErrLimit = errors.New("limit reached")

ErrLimit indicates that the limit of the LimitedByteWriter has been reached.

View Source
var ErrNoSpace = errors.New("insufficient space")

ErrNoSpace indicates that there is insufficient space for the Write operation.

Functions

func ByteReader

func ByteReader(r io.Reader) io.ByteReader

ByteReader converts an io.Reader into an io.ByteReader.

func ValidHeader

func ValidHeader(data []byte) bool

ValidHeader checks for a valid LZMA file header. It allows only dictionary sizes of 2^n or 2^n+2^(n-1) with n >= 10 or 2^32-1. If there is an explicit size it must not exceed 256 GiB. The length of the data argument must be HeaderLen.

Types

type LimitedByteWriter

type LimitedByteWriter struct {
	BW io.ByteWriter
	N  int64
}

LimitedByteWriter provides a byte writer that can be written until a limit is reached. The field N provides the number of remaining bytes.

func (*LimitedByteWriter) WriteByte

func (l *LimitedByteWriter) WriteByte(c byte) error

WriteByte writes a single byte to the limited byte writer. It returns ErrLimit if the limit has been reached. If the byte is successfully written the field N of the LimitedByteWriter will be decremented by one.

type Properties

type Properties struct {
	LC int
	LP int
	PB int
}

Properties contains the parameters LC, LP and PB. The parameter LC defines the number of literal context bits; parameter LP the number of literal position bits and PB the number of position bits.

func PropertiesForCode

func PropertiesForCode(code byte) (p Properties, err error)

PropertiesForCode converts a properties code byte into a Properties value.

func (Properties) Code

func (p Properties) Code() byte

Code converts the properties to a byte. The function assumes that the properties components are all in range.

func (*Properties) String

func (p *Properties) String() string

String returns the properties in a string representation.

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader provides a reader for LZMA files or streams.

func NewReader

func NewReader(lzma io.Reader) (r *Reader, err error)

NewReader creates a new reader for an LZMA stream using the classic format. NewReader reads and checks the header of the LZMA stream.

func (*Reader) EOSMarker

func (r *Reader) EOSMarker() bool

EOSMarker indicates that an EOS marker has been encountered.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read returns uncompressed data.

type ReaderConfig

type ReaderConfig struct {
	DictCap int
}

ReaderConfig stores the parameters for the reader of the classic LZMA format.

func (ReaderConfig) NewReader

func (c ReaderConfig) NewReader(lzma io.Reader) (r *Reader, err error)

NewReader creates a new reader for an LZMA stream in the classic format. The function reads and verifies the the header of the LZMA stream.

func (*ReaderConfig) Verify

func (c *ReaderConfig) Verify() error

Verify checks the reader configuration for errors. Zero values will be replaced by default values.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL