mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-03 20:27:35 +03:00
26 lines
481 B
Go
26 lines
481 B
Go
package utils
|
|
|
|
import (
|
|
"bufio"
|
|
"io"
|
|
)
|
|
|
|
type bufferedWriteCloser struct {
|
|
*bufio.Writer
|
|
io.Closer
|
|
}
|
|
|
|
// NewBufferedWriteCloser creates an io.WriteCloser from a bufio.Writer and an io.Closer
|
|
func NewBufferedWriteCloser(writer *bufio.Writer, closer io.Closer) io.WriteCloser {
|
|
return &bufferedWriteCloser{
|
|
Writer: writer,
|
|
Closer: closer,
|
|
}
|
|
}
|
|
|
|
func (h bufferedWriteCloser) Close() error {
|
|
if err := h.Writer.Flush(); err != nil {
|
|
return err
|
|
}
|
|
return h.Closer.Close()
|
|
}
|