-
Notifications
You must be signed in to change notification settings - Fork 0
/
lzma2.go
47 lines (39 loc) · 676 Bytes
/
lzma2.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
40
41
42
43
44
45
46
47
package iokit
import (
"github.com/ulikunitz/xz"
"io"
)
type lzma2 struct {
Output
}
func Lzma2(output Output) StrictOutput {
return StrictOutput{lzma2{output}}
}
type lzma2wr struct {
wl io.WriteCloser
wh Whole
}
func (lz lzma2) Create() (wh Whole, err error) {
w, err := lz.Output.Create()
if err != nil {
return
}
wx, err := xz.NewWriter(w)
if err != nil {
return
}
return &lzma2wr{wx, w}, nil
}
func (lz *lzma2wr) Commit() error {
if err := lz.wl.Close(); err != nil {
return err
}
return lz.wh.Commit()
}
func (lz *lzma2wr) End() {
_ = lz.wl.Close()
lz.wh.End()
}
func (lz *lzma2wr) Write(b []byte) (int, error) {
return lz.wl.Write(b)
}