Пример #1
0
func NewReader(r io.Reader) (*Decompressor, error) {
	dec := new(Decompressor)
	dec.rd = r
	dec.buffer = make([]byte, DefaultBufsize)
	dec.offset = DefaultBufsize
	dec.handle = allocLzmaStream(dec.handle)
	// Initialize decoder
	ret := C.lzma_auto_decoder(dec.handle, math.MaxUint64, 0)
	if Errno(ret) != Ok {
		return nil, Errno(ret)
	}

	return dec, nil
}
Пример #2
0
func NewReader(r io.Reader) (*Decompressor, error) {
	dec := new(Decompressor)
	// The zero lzma_stream is the same thing as LZMA_STREAM_INIT.
	dec.rd = r
	dec.buffer = make([]byte, DefaultBufsize)
	dec.offset = DefaultBufsize

	// Initialize decoder
	ret := C.lzma_auto_decoder(&dec.handle, math.MaxUint64, 0)
	if Errno(ret) != Ok {
		return nil, Errno(ret)
	}

	return dec, nil
}