1
0
Fork 0
mirror of https://github.com/Luzifer/gallery.git synced 2024-11-14 00:42:43 +00:00
gallery/vendor/github.com/cheggaaa/pb/reader.go
Knut Ahlers 7eea7aaa62
Vendor dependencies
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-04-28 22:10:37 +02:00

26 lines
514 B
Go

package pb
import (
"io"
)
// Reader it's a wrapper for given reader, but with progress handle
type Reader struct {
io.Reader
bar *ProgressBar
}
// Read reads bytes from wrapped reader and add amount of bytes to progress bar
func (r *Reader) Read(p []byte) (n int, err error) {
n, err = r.Reader.Read(p)
r.bar.Add(n)
return
}
// Close the wrapped reader when it implements io.Closer
func (r *Reader) Close() (err error) {
if closer, ok := r.Reader.(io.Closer); ok {
return closer.Close()
}
return
}