MCPcopy Create free account
hub / github.com/diasurgical/devilution / FlatStream_CheckFile

Function FlatStream_CheckFile

3rdParty/StormLib/src/FileStream.cpp:1067–1091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1065// Local functions - flat stream support
1066
1067static DWORD FlatStream_CheckFile(TBlockStream * pStream)
1068{
1069 LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap;
1070 DWORD WholeByteCount = (pStream->BlockCount / 8);
1071 DWORD ExtraBitsCount = (pStream->BlockCount & 7);
1072 BYTE ExpectedValue;
1073
1074 // Verify the whole bytes - their value must be 0xFF
1075 for(DWORD i = 0; i < WholeByteCount; i++)
1076 {
1077 if(FileBitmap[i] != 0xFF)
1078 return 0;
1079 }
1080
1081 // If there are extra bits, calculate the mask
1082 if(ExtraBitsCount != 0)
1083 {
1084 ExpectedValue = (BYTE)((1 << ExtraBitsCount) - 1);
1085 if(FileBitmap[WholeByteCount] != ExpectedValue)
1086 return 0;
1087 }
1088
1089 // Yes, the file is complete
1090 return 1;
1091}
1092
1093static bool FlatStream_LoadBitmap(TBlockStream * pStream)
1094{

Callers 1

FlatStream_LoadBitmapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected