(buf *readerBuffer)
| 63 | } |
| 64 | |
| 65 | func (r *BufferedReaderAt) populate(buf *readerBuffer) (int, error) { |
| 66 | // read |
| 67 | n, err := r.ra.ReadAt(buf.buf, buf.off) |
| 68 | |
| 69 | // if err is fatal we need to invalidate the buffer by setting it back to 0s (uninitialized) |
| 70 | if isFatalError(err) { |
| 71 | buf.buf = buf.buf[:0] |
| 72 | buf.count = 0 |
| 73 | buf.off = 0 |
| 74 | } |
| 75 | |
| 76 | return n, err |
| 77 | } |
| 78 | |
| 79 | func calculateBounds(offset, length int64, bufferSize int, readerAtSize int64) (newOffset, newLength int64) { |
| 80 | // Increase to minimim read size |