5d0816430f
* rename pkg/linksharing to linksharing * rename pkg/httpserver to linksharing/httpserver * rename pkg/eestream to uplink/eestream * rename pkg/stream to uplink/stream * rename pkg/metainfo/kvmetainfo to uplink/metainfo/kvmetainfo * rename pkg/auth/signing to pkg/signing * rename pkg/storage to uplink/storage * rename pkg/accounting to satellite/accounting * rename pkg/audit to satellite/audit * rename pkg/certdb to satellite/certdb * rename pkg/discovery to satellite/discovery * rename pkg/overlay to satellite/overlay * rename pkg/datarepair to satellite/repair
29 lines
593 B
Go
29 lines
593 B
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package streams
|
|
|
|
import "io"
|
|
|
|
// SizeReader holds reader and size read so far
|
|
type SizeReader struct {
|
|
reader io.Reader
|
|
size int64
|
|
}
|
|
|
|
// NewSizeReader keeps track of how much bytes are read from the reader
|
|
func NewSizeReader(r io.Reader) *SizeReader {
|
|
return &SizeReader{reader: r}
|
|
}
|
|
|
|
func (r *SizeReader) Read(p []byte) (n int, err error) {
|
|
n, err = r.reader.Read(p)
|
|
r.size += int64(n)
|
|
return n, err
|
|
}
|
|
|
|
// Size returns the number of bytes read so far
|
|
func (r *SizeReader) Size() int64 {
|
|
return r.size
|
|
}
|