Move changes from exp2 to main
This is largely a move to simplify a lot of the readers Also further breaks out functions.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package decompress
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/klauspost/compress/zlib"
|
||||
)
|
||||
|
||||
type GZip struct{}
|
||||
|
||||
func (g GZip) Reader(src io.Reader) (io.ReadCloser, error) {
|
||||
return zlib.NewReader(src)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package decompress
|
||||
|
||||
import "io"
|
||||
|
||||
type Decompressor interface {
|
||||
Reader(src io.Reader) (io.ReadCloser, error)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package decompress
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/pierrec/lz4/v4"
|
||||
)
|
||||
|
||||
type Lz4 struct{}
|
||||
|
||||
func (l Lz4) Reader(r io.Reader) (io.ReadCloser, error) {
|
||||
return io.NopCloser(lz4.NewReader(r)), nil
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package decompress
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/ulikunitz/xz/lzma"
|
||||
)
|
||||
|
||||
type Lzma struct{}
|
||||
|
||||
func (l Lzma) Reader(r io.Reader) (io.ReadCloser, error) {
|
||||
rdr, err := lzma.NewReader(r)
|
||||
return io.NopCloser(rdr), err
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package decompress
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
|
||||
"github.com/rasky/go-lzo"
|
||||
)
|
||||
|
||||
type Lzo struct{}
|
||||
|
||||
func (l Lzo) Reader(r io.Reader) (io.ReadCloser, error) {
|
||||
cache, err := lzo.Decompress1X(r, 0, 0)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return io.NopCloser(bytes.NewReader(cache)), nil
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package decompress
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/therootcompany/xz"
|
||||
)
|
||||
|
||||
type Xz struct{}
|
||||
|
||||
func (x Xz) Reader(r io.Reader) (io.ReadCloser, error) {
|
||||
rdr, err := xz.NewReader(r, 0)
|
||||
return io.NopCloser(rdr), err
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package decompress
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/klauspost/compress/zstd"
|
||||
)
|
||||
|
||||
type Zstd struct{}
|
||||
|
||||
func (z Zstd) Reader(src io.Reader) (io.ReadCloser, error) {
|
||||
r, err := zstd.NewReader(src)
|
||||
return r.IOReadCloser(), err
|
||||
}
|
||||
Reference in New Issue
Block a user