MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Fill

Method Fill

src/streams.h:515–529  ·  view source on GitHub ↗

read data from the source to fill the buffer

Source from the content-addressed store, hash-verified

513
514 //! read data from the source to fill the buffer
515 bool Fill() {
516 unsigned int pos = nSrcPos % vchBuf.size();
517 unsigned int readNow = vchBuf.size() - pos;
518 unsigned int nAvail = vchBuf.size() - (nSrcPos - m_read_pos) - nRewind;
519 if (nAvail < readNow)
520 readNow = nAvail;
521 if (readNow == 0)
522 return false;
523 size_t nBytes{m_src.detail_fread(std::span{vchBuf}.subspan(pos, readNow))};
524 if (nBytes == 0) {
525 throw std::ios_base::failure{m_src.feof() ? "BufferedFile::Fill: end of file" : "BufferedFile::Fill: fread failed"};
526 }
527 nSrcPos += nBytes;
528 return true;
529 }
530
531 //! Advance the stream's read pointer (m_read_pos) by up to 'length' bytes,
532 //! filling the buffer from the file so that at least one byte is available.

Callers

nothing calls this directly

Calls 3

detail_freadMethod · 0.80
feofMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected