package multifile import ( "io" "os" "gitlab.com/tozd/go/errors" ) 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) (int, error) { n, err := cw.Writer.Write(p) if err != nil { return 0, errors.WithStack(err) } return n, nil } func (cw *CompressWriter) Close() error { return errors.WithStack(errors.Join(cw.Writer.Close(), cw.File.Close())) }