1package moxio
2
3import (
4 "io"
5)
6
7// AtReader is turns an io.ReaderAt into a io.Reader by keeping track of the
8// offset.
9type AtReader struct {
10 R io.ReaderAt
11 Offset int64
12}
13
14func (r *AtReader) Read(buf []byte) (int, error) {
15 n, err := r.R.ReadAt(buf, r.Offset)
16 if n > 0 {
17 r.Offset += int64(n)
18 }
19 return n, err
20}
21