MCPcopy Create free account
hub / github.com/AbyssEngine/AbyssEngineOld / seekoff

Method seekoff

src/Abyss/FileSystem/CASC.cpp:58–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56CASCStream::pos_type CASCStream::seekpos(pos_type pos, std::ios_base::openmode which) { return seekoff(pos, std::ios_base::beg, which); }
57
58CASCStream::pos_type CASCStream::seekoff(off_type off, std::ios_base::seekdir dir, std::ios_base::openmode) {
59 std::streamsize newPos = 0;
60 switch (dir) {
61 case std::ios_base::beg:
62 newPos = off;
63 break;
64 case std::ios_base::cur:
65 newPos = _startOfBlock + (gptr() - eback()) + off;
66 break;
67 case std::ios_base::end:
68 newPos = size() + off;
69 break;
70 default:
71 break;
72 }
73 if (newPos >= _startOfBlock && newPos < _startOfBlock + (egptr() - eback())) {
74 // The new position is already in the buffer, just repoint the pointer to it
75 setg(eback(), eback() + newPos - _startOfBlock, egptr());
76 } else {
77 // Drop buffer, it will be read in underflow
78 CascSetFilePointer64(_file, newPos, nullptr, 0);
79 setg(nullptr, nullptr, nullptr);
80 _startOfBlock = newPos;
81 }
82 return _startOfBlock + (gptr() - eback());
83}
84
85std::streamsize CASCStream::size() const {
86 ULONGLONG ulongsize;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected