From 3f335cabfc8d70724a7c345a86ab7a444afb087d Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 26 Feb 2015 16:10:38 +1100 Subject: [PATCH] Implement File.ReadAt --- client.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/client.go b/client.go index 2fff46a9..9a897612 100644 --- a/client.go +++ b/client.go @@ -1675,6 +1675,14 @@ type File struct { metainfo.FileInfo } +func (f File) ReadAt(p []byte, off int64) (n int, err error) { + maxLen := f.length - off + if int64(len(p)) > maxLen { + p = p[:maxLen] + } + return f.t.ReadAt(p, off+f.offset) +} + func (f *File) Length() int64 { return f.length }