/
githubmirror
/
rclone
Обзор
Документация
Войти
/
githubmirror
/
rclone
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
lib/readers/counting_reader.go
28 строк
716 B
Nick Craig-Wood
Break the fs package up into smaller parts.
15 янв 2018, 20:51
15 янв 2018, 20:51
11da2a6
Код
Авторство
О чём код?
package readers import "io" // NewCountingReader returns a CountingReader, which will read from the given // reader while keeping track of how many bytes were read. func NewCountingReader(in io.Reader) *CountingReader { return &CountingReader{in: in} } // CountingReader holds a reader and a read count of how many bytes were read // so far. type CountingReader struct { in io.Reader read uint64 } // Read reads from the underlying reader. func (cr *CountingReader) Read(b []byte) (int, error) { n, err := cr.in.Read(b) cr.read += uint64(n) return n, err } // BytesRead returns how many bytes were read from the underlying reader so far. func (cr *CountingReader) BytesRead() uint64 { return cr.read }