* Read a block. * @param ptr Destination buffer. * @param size Number of bytes to read. */
| 143 | * @param size Number of bytes to read. |
| 144 | */ |
| 145 | void RandomAccessFile::ReadBlock(void *ptr, size_t size) |
| 146 | { |
| 147 | if (this->buffer != this->buffer_end) { |
| 148 | size_t to_copy = std::min<size_t>(size, this->buffer_end - this->buffer); |
| 149 | std::copy_n(this->buffer, to_copy, static_cast<uint8_t *>(ptr)); |
| 150 | this->buffer += to_copy; |
| 151 | size -= to_copy; |
| 152 | if (size == 0) return; |
| 153 | ptr = static_cast<char *>(ptr) + to_copy; |
| 154 | } |
| 155 | |
| 156 | this->pos += fread(ptr, 1, size, *this->file_handle); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Skip \a n bytes ahead in the file. |
no outgoing calls
no test coverage detected