Changeset View
Changeset View
Standalone View
Standalone View
src/streams.h
Show First 20 Lines • Show All 809 Lines • ▼ Show 20 Lines | bool SetPos(uint64_t nPos) { | ||||
// can't go this far forward, go as far as possible | // can't go this far forward, go as far as possible | ||||
nReadPos = nSrcPos; | nReadPos = nSrcPos; | ||||
return false; | return false; | ||||
} | } | ||||
nReadPos = nPos; | nReadPos = nPos; | ||||
return true; | return true; | ||||
} | } | ||||
bool Seek(uint64_t nPos) { | |||||
long nLongPos = nPos; | |||||
if (nPos != (uint64_t)nLongPos) { | |||||
return false; | |||||
} | |||||
if (fseek(src, nLongPos, SEEK_SET)) { | |||||
return false; | |||||
} | |||||
nLongPos = ftell(src); | |||||
nSrcPos = nLongPos; | |||||
nReadPos = nLongPos; | |||||
return true; | |||||
} | |||||
//! Prevent reading beyond a certain position. No argument removes the | //! Prevent reading beyond a certain position. No argument removes the | ||||
//! limit. | //! limit. | ||||
bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) { | bool SetLimit(uint64_t nPos = std::numeric_limits<uint64_t>::max()) { | ||||
if (nPos < nReadPos) { | if (nPos < nReadPos) { | ||||
return false; | return false; | ||||
} | } | ||||
nReadLimit = nPos; | nReadLimit = nPos; | ||||
return true; | return true; | ||||
Show All 23 Lines |