Implement File.ReadAt

This commit is contained in:
Matt Joiner 2015-02-26 16:10:38 +11:00
parent 9ffb9b0b88
commit 3f335cabfc
1 changed files with 8 additions and 0 deletions

View File

@ -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
}