mirror of
https://github.com/restic/restic.git
synced 2025-03-30 00:00:14 +01:00
Add ContinuousReader
This commit is contained in:
parent
f319354174
commit
e0361b1f9f
1 changed files with 23 additions and 0 deletions
23
backend/s3/cont_reader.go
Normal file
23
backend/s3/cont_reader.go
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package s3
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ContinuousReader implements an io.Reader on top of an io.ReaderAt, advancing
|
||||||
|
// an offset.
|
||||||
|
type ContinuousReader struct {
|
||||||
|
R io.ReaderAt
|
||||||
|
Offset int64
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ContinuousReader) Read(p []byte) (int, error) {
|
||||||
|
fmt.Printf("ContinuousReader %p: ReadAt(offset %v)\n", c, c.Offset)
|
||||||
|
n, err := c.R.ReadAt(p, c.Offset)
|
||||||
|
fmt.Printf("ContinuousReader %p: len(p) = %v, n %v, err %v\n",
|
||||||
|
c, len(p), n, err)
|
||||||
|
fmt.Printf(" %02x\n", p[:n])
|
||||||
|
c.Offset += int64(n)
|
||||||
|
return n, err
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue