MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / ReadOverlapped

Method ReadOverlapped

engine/Poseidon/IO/Streams/QBStream.cpp:958–992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

956bool QFBank::FileExists(const char* name) const
957{
958 if (!Load())
959 {
960 return false;
961 }
962 const FileInfoO& info = FindFileInfo(name);
963 return NotNull(info);
964}
965
966void QFBank::Seek(long pos) const
967{
968 EXCLUSIVE();
969 _wantPos = pos;
970}
971
972void QFBank::Read(char* buf, long size, const char* name) const
973{
974 PoseidonAssert(!_error);
975 BEG_SERIALIZE
976 EXCLUSIVE(); // seek to wanted position
977 if (_pos != _wantPos)
978 {
979 DWORD nPos = SetFilePointer(_handle, _wantPos, nullptr, FILE_BEGIN);
980 if ((int)nPos != _wantPos)
981 {
982 Foundation::ErrorMessage("Read: Data file seek error (%s: %d,%d).", name, nPos, _wantPos);
983 }
984 else
985 {
986 _pos = nPos;
987 }
988 }
989 // read into the temporary buffer
990 DWORD bytes;
991 if (!ReadFile(_handle, buf, size, &bytes, nullptr) || (int)bytes != size)
992 {
993 Foundation::ErrorMessage("Data file read error (%s).", name);
994 }
995 _pos += bytes;

Callers 1

UpdateMethod · 0.80

Calls 1

ReadFunction · 0.85

Tested by

no test coverage detected