internal/multifile/compress.go (view raw)
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 | package multifile
import (
"errors"
"io"
"os"
)
type CompressWriter struct {
*os.File
Writer io.WriteCloser
}
func NewCompressWriter(file *os.File, writer io.WriteCloser) *CompressWriter {
return &CompressWriter{
File: file,
Writer: writer,
}
}
func (cw *CompressWriter) Write(p []byte) (n int, err error) {
return cw.Writer.Write(p)
}
func (cw *CompressWriter) Close() error {
return errors.Join(cw.Writer.Close(), cw.File.Close())
}
|