Documentation ¶
Index ¶
Constants ¶
const ( MinDictCap = 1 << 12 MaxDictCap = 1<<32 - 1 )
const HeaderLen = 6
HeaderLen provides the length of the LZMA file header.
Variables ¶
var ErrLimit = errors.New("limit reached")
ErrLimit indicates that the limit of the LimitedByteWriter has been reached.
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 ¶
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 ¶
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 ¶
NewReader creates a new reader for an LZMA stream using the classic format. NewReader reads and checks the header of the LZMA stream.
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.