Files
drive/apps/backend/internal/ioext/counting_reader.go

24 lines
381 B
Go
Raw Normal View History

2025-11-28 22:31:00 +00:00
package ioext
2025-11-27 20:49:58 +00:00
import "io"
type CountingReader struct {
reader io.Reader
count int64
}
func NewCountingReader(reader io.Reader) *CountingReader {
return &CountingReader{reader: reader}
}
func (r *CountingReader) Read(p []byte) (n int, err error) {
n, err = r.reader.Read(p)
r.count += int64(n)
return n, err
}
func (r *CountingReader) Count() int64 {
return r.count
}
2025-11-28 22:31:00 +00:00