(offset, length int64, bufferSize int, readerAtSize int64)
| 77 | } |
| 78 | |
| 79 | func calculateBounds(offset, length int64, bufferSize int, readerAtSize int64) (newOffset, newLength int64) { |
| 80 | // Increase to minimim read size |
| 81 | sz := length |
| 82 | if sz < int64(bufferSize) { |
| 83 | sz = int64(bufferSize) |
| 84 | } |
| 85 | |
| 86 | // Don't read larger than entire contents |
| 87 | if sz > readerAtSize { |
| 88 | sz = readerAtSize |
| 89 | } |
| 90 | |
| 91 | // If read extends past the end of reader, |
| 92 | // back offset up to fill the whole buffer |
| 93 | if offset+sz >= readerAtSize { |
| 94 | offset = readerAtSize - sz |
| 95 | } |
| 96 | |
| 97 | return offset, sz |
| 98 | } |
| 99 | |
| 100 | func (r *BufferedReaderAt) ReadAt(b []byte, offset int64) (int, error) { |
| 101 | r.mtx.Lock() |
no outgoing calls