rewind to a given reading position
| 676 | |
| 677 | //! rewind to a given reading position |
| 678 | bool SetPos(uint64_t nPos) { |
| 679 | size_t bufsize = vchBuf.size(); |
| 680 | if (nPos + bufsize < nSrcPos) { |
| 681 | // rewinding too far, rewind as far as possible |
| 682 | m_read_pos = nSrcPos - bufsize; |
| 683 | return false; |
| 684 | } |
| 685 | if (nPos > nSrcPos) { |
| 686 | // can't go this far forward, go as far as possible |
| 687 | m_read_pos = nSrcPos; |
| 688 | return false; |
| 689 | } |
| 690 | m_read_pos = nPos; |
| 691 | return true; |
| 692 | } |
| 693 | |
| 694 | //! prevent reading beyond a certain position |
| 695 | //! no argument removes the limit |