Changeset View
Changeset View
Standalone View
Standalone View
src/streams.h
Show First 20 Lines • Show All 740 Lines • ▼ Show 20 Lines | bool Fill() { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
public: | public: | ||||
CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, | CBufferedFile(FILE *fileIn, uint64_t nBufSize, uint64_t nRewindIn, | ||||
int nTypeIn, int nVersionIn) | int nTypeIn, int nVersionIn) | ||||
: nType(nTypeIn), nVersion(nVersionIn), nSrcPos(0), nReadPos(0), | : nType(nTypeIn), nVersion(nVersionIn), nSrcPos(0), nReadPos(0), | ||||
nReadLimit((uint64_t)(-1)), nRewind(nRewindIn), vchBuf(nBufSize, 0) { | nReadLimit(std::numeric_limits<uint64_t>::max()), nRewind(nRewindIn), | ||||
vchBuf(nBufSize, 0) { | |||||
src = fileIn; | src = fileIn; | ||||
} | } | ||||
~CBufferedFile() { fclose(); } | ~CBufferedFile() { fclose(); } | ||||
// Disallow copies | // Disallow copies | ||||
CBufferedFile(const CBufferedFile &) = delete; | CBufferedFile(const CBufferedFile &) = delete; | ||||
CBufferedFile &operator=(const CBufferedFile &) = delete; | CBufferedFile &operator=(const CBufferedFile &) = delete; | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | bool Seek(uint64_t nPos) { | ||||
} | } | ||||
nLongPos = ftell(src); | nLongPos = ftell(src); | ||||
nSrcPos = nLongPos; | nSrcPos = nLongPos; | ||||
nReadPos = nLongPos; | nReadPos = nLongPos; | ||||
return true; | return true; | ||||
} | } | ||||
// Prevent reading beyond a certain position. No argument removes the limit. | // 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) { | if (nPos < nReadPos) { | ||||
return false; | return false; | ||||
} | } | ||||
nReadLimit = nPos; | nReadLimit = nPos; | ||||
return true; | return true; | ||||
} | } | ||||
template <typename T> CBufferedFile &operator>>(T &&obj) { | template <typename T> CBufferedFile &operator>>(T &&obj) { | ||||
Show All 20 Lines |