-
Notifications
You must be signed in to change notification settings - Fork 2
/
lzfse.go
39 lines (32 loc) · 996 Bytes
/
lzfse.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package mutators
import (
"bytes"
"io"
"github.com/batmac/ccat/pkg/log"
lzfse_go "github.com/aixiansheng/lzfse"
// "github.com/blacktop/lzfse-cgo"
)
func init() {
// singleRegister("unlzfse-c", unlzfse, withDescription("decompress lzfse data"))
singleRegister("unlzfse", unlzfseGo, withDescription("decompress lzfse data"),
withCategory("decompress"),
)
// singleRegister("lzfse", clzfse, withDescription("compress lzfse data"))
}
/* func unlzfse(out io.WriteCloser, in io.ReadCloser) (int64, error) {
dat, err := io.ReadAll(in)
if err != nil {
log.Fatal("failed to read compressed file: ", err)
}
decompressed := lzfse.DecodeBuffer(dat)
d := bytes.NewReader(decompressed)
return io.Copy(out, d)
} */
func unlzfseGo(out io.WriteCloser, in io.ReadCloser, _ any) (int64, error) {
dat, err := io.ReadAll(in) // NOT streamable
if err != nil {
log.Fatal("failed to read compressed file: ", err)
}
d := lzfse_go.NewReader(bytes.NewReader(dat))
return io.Copy(out, d)
}