This commit is contained in:
Mechiel Lukkien
2023-01-30 14:27:06 +01:00
commit cb229cb6cf
1256 changed files with 491723 additions and 0 deletions

20
moxio/atreader.go Normal file
View File

@ -0,0 +1,20 @@
package moxio
import (
"io"
)
// AtReader is turns an io.ReaderAt into a io.Reader by keeping track of the
// offset.
type AtReader struct {
R io.ReaderAt
Offset int64
}
func (r *AtReader) Read(buf []byte) (int, error) {
n, err := r.R.ReadAt(buf, r.Offset)
if n > 0 {
r.Offset += int64(n)
}
return n, err
}