Re-wrote a bunch to try to figure out why things weren't working.
Turned out I was reading if a block was compressed exactly opposite. Started to work more on looking up dirs.
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package squashfs
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/zlib"
|
||||
"io"
|
||||
)
|
||||
|
||||
type Decompressor interface {
|
||||
Decompress(io.Reader) ([]byte, error)
|
||||
DecompressCopy(*io.Writer, *io.SectionReader) error
|
||||
}
|
||||
|
||||
type ZlibDecompressor struct{}
|
||||
|
||||
func (z *ZlibDecompressor) 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
|
||||
}
|
||||
|
||||
func (z *ZlibDecompressor) DecompressCopy(w *io.Writer, r *io.SectionReader) error {
|
||||
rdr, err := zlib.NewReader(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = io.Copy(*w, rdr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user