1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 // buffer buffers an io.Reader to satisfy io.ReaderAt.
18 func (b *buffer) ReadAt(p []byte, off int64) (int, os.Error) {
21 if int64(end) != off+int64(len(p)) {
32 newbuf := make([]byte, end, newcap)
38 if n, err := io.ReadFull(b.r, b.buf[m:end]); err != nil {
41 return copy(p, b.buf[o:end]), err
45 return copy(p, b.buf[o:end]), nil
48 // newReaderAt converts an io.Reader into an io.ReaderAt.
49 func newReaderAt(r io.Reader) io.ReaderAt {
50 if ra, ok := r.(io.ReaderAt); ok {
55 buf: make([]byte, 0, 1024),