MCPcopy Create free account
hub / github.com/Scobalula/Greyhound / FlatStream_CheckFile

Function FlatStream_CheckFile

src/External/CascLib/src/common/FileStream.cpp:1106–1130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1104// Local functions - flat stream support
1105
1106static DWORD FlatStream_CheckFile(TBlockStream * pStream)
1107{
1108 LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap;
1109 DWORD WholeByteCount = (pStream->BlockCount / 8);
1110 DWORD ExtraBitsCount = (pStream->BlockCount & 7);
1111 BYTE ExpectedValue;
1112
1113 // Verify the whole bytes - their value must be 0xFF
1114 for(DWORD i = 0; i < WholeByteCount; i++)
1115 {
1116 if(FileBitmap[i] != 0xFF)
1117 return 0;
1118 }
1119
1120 // If there are extra bits, calculate the mask
1121 if(ExtraBitsCount != 0)
1122 {
1123 ExpectedValue = (BYTE)((1 << ExtraBitsCount) - 1);
1124 if(FileBitmap[WholeByteCount] != ExpectedValue)
1125 return 0;
1126 }
1127
1128 // Yes, the file is complete
1129 return 1;
1130}
1131
1132static bool FlatStream_LoadBitmap(TBlockStream * pStream)
1133{

Callers 1

FlatStream_LoadBitmapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected