storj/uplink/storage/segments/size.go
Egon Elbre 5d0816430f
rename all the things (#2531)
* 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
2019-07-28 08:55:36 +03:00

30 lines
629 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package segments
import (
"io"
)
// SizedReader allows to check the total number of bytes read so far.
type SizedReader struct {
r io.Reader
size int64
}
// SizeReader create a new instance of SizedReader.
func SizeReader(r io.Reader) *SizedReader {
return &SizedReader{r: r}
}
// Read implements io.Reader.Read
func (r *SizedReader) Read(p []byte) (n int, err error) {
n, err = r.r.Read(p)
r.size += int64(n)
return n, err
}
// Size returns the total number of bytes read so far.
func (r *SizedReader) Size() int64 { return r.size }