Files
squashfs/internal/compression/zlib.go
T
Caleb Gardner e20213c3f7 Reorganization.
2020-11-28 05:03:56 -06:00

25 lines
478 B
Go

package compression
import (
"bytes"
"compress/zlib"
"io"
)
//Zlib is a decompressor for gzip type compression
type Zlib struct{}
//Decompress reads the entirety of the given reader and returns it uncompressed as a byte slice.
func (z *Zlib) Decompress(r io.Reader) ([]byte, error) {
rdr, err := zlib.NewReader(r)
if err != nil {
return nil, err
}
var data bytes.Buffer
_, err = io.Copy(&data, rdr)
if err != nil {
return nil, err
}
return data.Bytes(), nil
}