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

Method ReadDataBlock

src/music/midifile.cpp:158–165  ·  view source on GitHub ↗

* Read bytes into a MidiFile::DataBlock. * @param[out] dest DataBlock to copy into * @param length number of bytes to read * @return true if the requested number of bytes were available */

Source from the content-addressed store, hash-verified

156 * @return true if the requested number of bytes were available
157 */
158 bool ReadDataBlock(MidiFile::DataBlock *dest, size_t length)
159 {
160 if (this->IsEnd()) return false;
161 if (this->buf.size() - this->pos < length) return false;
162 dest->data.insert(dest->data.end(), std::begin(this->buf) + this->pos, std::begin(this->buf) + this->pos + length);
163 this->pos += length;
164 return true;
165 }
166
167 /**
168 * Skip over a number of bytes in the buffer.

Callers 1

ReadTrackChunkFunction · 0.80

Calls 5

IsEndMethod · 0.95
beginFunction · 0.50
sizeMethod · 0.45
insertMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected