MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ReadBlock

Method ReadBlock

src/random_access_file.cpp:145–157  ·  view source on GitHub ↗

* Read a block. * @param ptr Destination buffer. * @param size Number of bytes to read. */

Source from the content-addressed store, hash-verified

143 * @param size Number of bytes to read.
144 */
145void 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.

Callers 10

LoadMethod · 0.80
DecodeSpecialSpriteFunction · 0.80
LoadMethod · 0.80
LoadNewGRFSoundFunction · 0.80
ReadRecolourSpriteFunction · 0.80
LoadMethod · 0.80
GetMusicCatEntryNameFunction · 0.80
GetMusicCatEntryDataFunction · 0.80
LoadBasesetSoundFunction · 0.80
CfgApplyFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected