rewind to a given reading position
| 588 | |
| 589 | //! rewind to a given reading position |
| 590 | bool SetPos(uint64_t nPos) { |
| 591 | size_t bufsize = vchBuf.size(); |
| 592 | if (nPos + bufsize < nSrcPos) { |
| 593 | // rewinding too far, rewind as far as possible |
| 594 | m_read_pos = nSrcPos - bufsize; |
| 595 | return false; |
| 596 | } |
| 597 | if (nPos > nSrcPos) { |
| 598 | // can't go this far forward, go as far as possible |
| 599 | m_read_pos = nSrcPos; |
| 600 | return false; |
| 601 | } |
| 602 | m_read_pos = nPos; |
| 603 | return true; |
| 604 | } |
| 605 | |
| 606 | //! prevent reading beyond a certain position |
| 607 | //! no argument removes the limit |