ReadAt reads from the backend handle h at the given position.
(ctx context.Context, be Backend, h Handle, offset int64, p []byte)
| 27 | |
| 28 | // ReadAt reads from the backend handle h at the given position. |
| 29 | func ReadAt(ctx context.Context, be Backend, h Handle, offset int64, p []byte) (n int, err error) { |
| 30 | debug.Log("ReadAt(%v) at %v, len %v", h, offset, len(p)) |
| 31 | |
| 32 | err = be.Load(ctx, h, len(p), offset, func(rd io.Reader) (ierr error) { |
| 33 | n, ierr = io.ReadFull(rd, p) |
| 34 | |
| 35 | return ierr |
| 36 | }) |
| 37 | if err != nil { |
| 38 | return 0, errors.Wrapf(err, "ReadFull(%v)", h) |
| 39 | } |
| 40 | |
| 41 | debug.Log("ReadAt(%v) ReadFull returned %v bytes", h, n) |
| 42 | return n, nil |
| 43 | } |