if (nReadPosNext >= vch.size())
{
if (nReadPosNext > vch.size())
- {
setstate(std::ios::failbit, "CDataStream::ignore() : end of data");
- nSize = (int)(vch.size() - nReadPos);
- }
nReadPos = 0;
vch.clear();
return (*this);
int nVersion;
CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, int nTypeIn, int nVersionIn) :
- src(fileIn), nSrcPos(0), nReadPos(0), nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0),
+ src(fileIn), nSrcPos(0), nReadPos(0), nReadLimit(std::numeric_limits<uint64_t>::max()), nRewind(nRewindIn), vchBuf(nBufSize, 0),
state(0), exceptmask(std::ios_base::badbit | std::ios_base::failbit), nType(nTypeIn), nVersion(nVersionIn) {
}
unsigned int pos = (unsigned int)(nReadPos % vchBuf.size());
size_t nNow = nSize;
if (nNow + pos > vchBuf.size())
- nNow = vchBuf.size() - pos;
+ nNow = (size_t)(vchBuf.size() - pos);
if (nNow + nReadPos > nSrcPos)
- nNow = nSrcPos - nReadPos;
+ nNow = (size_t)(nSrcPos - nReadPos);
memcpy(pch, &vchBuf[pos], nNow);
nReadPos += nNow;
pch += nNow;
// prevent reading beyond a certain position
// no argument removes the limit
- bool SetLimit(uint64_t nPos = (uint64_t)(-1)) {
+ bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) {
if (nPos < nReadPos)
return false;
nReadLimit = nPos;
// search for a given byte in the stream, and remain positioned on it
void FindByte(char ch) {
- while (true) {
+ for ( ; ; ) {
if (nReadPos == nSrcPos)
Fill();
if (vchBuf[nReadPos % vchBuf.size()] == ch)