| 63 | std::streambuf::pos_type MPQStream::seekpos(const pos_type pos, const std::ios_base::openmode which) { return seekoff(pos, std::ios_base::beg, which); } |
| 64 | |
| 65 | std::streambuf::pos_type MPQStream::seekoff(const off_type off, const std::ios_base::seekdir dir, std::ios_base::openmode which) { |
| 66 | std::streamsize newPos = 0; |
| 67 | switch (dir) { |
| 68 | case std::ios_base::beg: |
| 69 | newPos = off; |
| 70 | break; |
| 71 | case std::ios_base::cur: |
| 72 | newPos = _startOfBlock + (gptr() - eback()) + off; |
| 73 | break; |
| 74 | case std::ios_base::end: |
| 75 | newPos = size() + off; |
| 76 | break; |
| 77 | default: |
| 78 | break; |
| 79 | } |
| 80 | if (newPos >= _startOfBlock && newPos < _startOfBlock + (egptr() - eback())) { |
| 81 | // The new position is already in the buffer, just repoint the pointer to it |
| 82 | setg(eback(), eback() + newPos - _startOfBlock, egptr()); |
| 83 | } else { |
| 84 | // Drop buffer, it will be read in underflow |
| 85 | SFileSetFilePointer(_mpqFile, static_cast<int>(newPos), nullptr, 0); |
| 86 | setg(nullptr, nullptr, nullptr); |
| 87 | _startOfBlock = newPos; |
| 88 | } |
| 89 | return _startOfBlock + (gptr() - eback()); |
| 90 | } |
| 91 | |
| 92 | std::streamsize MPQStream::size() const { return SFileGetFileSize(_mpqFile, nullptr); } |
| 93 |
nothing calls this directly
no outgoing calls
no test coverage detected