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

Function FlatStream_UpdateBitmap

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

Source from the content-addressed store, hash-verified

1155}
1156
1157static void FlatStream_UpdateBitmap(
1158 TBlockStream * pStream, // Pointer to an open stream
1159 ULONGLONG StartOffset,
1160 ULONGLONG EndOffset)
1161{
1162 LPBYTE FileBitmap = (LPBYTE)pStream->FileBitmap;
1163 DWORD BlockIndex;
1164 DWORD BlockSize = pStream->BlockSize;
1165 DWORD ByteIndex;
1166 BYTE BitMask;
1167
1168 // Sanity checks
1169 assert((StartOffset & (BlockSize - 1)) == 0);
1170 assert(FileBitmap != NULL);
1171
1172 // Calculate the index of the block
1173 BlockIndex = (DWORD)(StartOffset / BlockSize);
1174 ByteIndex = (BlockIndex / 0x08);
1175 BitMask = (BYTE)(1 << (BlockIndex & 0x07));
1176
1177 // Set all bits for the specified range
1178 while(StartOffset < EndOffset)
1179 {
1180 // Set the bit
1181 FileBitmap[ByteIndex] |= BitMask;
1182
1183 // Move all
1184 StartOffset += BlockSize;
1185 ByteIndex += (BitMask >> 0x07);
1186 BitMask = (BitMask >> 0x07) | (BitMask << 0x01);
1187 }
1188
1189 // Increment the bitmap update count
1190 pStream->IsModified = 1;
1191}
1192
1193static bool FlatStream_BlockCheck(
1194 TBlockStream * pStream, // Pointer to an open stream

Callers 1

FlatStream_BlockReadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected