mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 10:34:40 +03:00
mox!
This commit is contained in:
20
moxio/atreader.go
Normal file
20
moxio/atreader.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user