From 3fd1e4a992a1952976846c55ccb9b721f8d059be Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 25 Aug 2016 21:49:00 +0200 Subject: [PATCH] Add backend.ReaderAt --- src/restic/backend/readerat.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/restic/backend/readerat.go diff --git a/src/restic/backend/readerat.go b/src/restic/backend/readerat.go new file mode 100644 index 000000000..027b34456 --- /dev/null +++ b/src/restic/backend/readerat.go @@ -0,0 +1,19 @@ +package backend + +import ( + "io" +) + +type backendReaderAt struct { + be Backend + h Handle +} + +func (brd backendReaderAt) ReadAt(p []byte, off int64) (n int, err error) { + return brd.be.Load(brd.h, p, off) +} + +// ReaderAt returns an io.ReaderAt for a file in the backend. +func ReaderAt(be Backend, h Handle) io.ReaderAt { + return backendReaderAt{be: be, h: h} +}