2019-01-06 21:48:13 +03:00
|
|
|
package mapblockparser
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
)
|
|
|
|
|
|
|
|
type CountedReader struct {
|
|
|
|
Reader *bytes.Reader
|
2019-01-13 18:37:03 +03:00
|
|
|
Count int
|
2019-01-06 21:48:13 +03:00
|
|
|
}
|
|
|
|
|
2019-01-13 18:37:03 +03:00
|
|
|
func (r *CountedReader) Read(p []byte) (int, error) {
|
|
|
|
i, err := r.Reader.Read(p)
|
2019-01-06 21:48:13 +03:00
|
|
|
r.Count += i
|
|
|
|
return i, err
|
|
|
|
}
|
|
|
|
|
2019-01-13 18:37:03 +03:00
|
|
|
func (r *CountedReader) ReadByte() (byte, error) {
|
|
|
|
i, err := r.Reader.ReadByte()
|
2019-01-06 21:48:13 +03:00
|
|
|
r.Count++
|
|
|
|
return i, err
|
2019-01-13 18:37:03 +03:00
|
|
|
}
|