read data from the source to fill the buffer
| 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. |
nothing calls this directly
no test coverage detected