Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // At start ensure that all data records are loaded
- for (size_t i = 0; i < mHeaderRecords.size(); i++)
- {
- if (mHeaderRecords[i].GetFilename() != nullptr && mHeaderRecords[i].GetFilename()[0] != '\0' && mHeaderRecords[i].GetOffset() != 0)
- {
- if (mDataRecords[i] == nullptr)
- {
- ReadRecord(i);
- }
- }
- }
- // Prior to saving, offsets have to be re-calculated, skipping the files that are not supposed
- // to be saved (i.e. those with empty names)
- size_t offset = mHeader.GetSize();
- size_t count = 0;
- for (size_t i = 0; i < mHeaderRecords.size(); i++)
- {
- if (mHeaderRecords[i].GetFilename() == nullptr || mHeaderRecords[i].GetFilename()[0] == '\0')
- {
- offset += 0;
- }
- else
- {
- offset += mDataRecords[i]->GetSize();
- count++;
- }
- }
- // Update record count in header
- mHeader.mRecordCount = count;
- offset += mBody.GetSize();
- for (size_t i = 0; i < mHeaderRecords.size(); i++)
- {
- if (mHeaderRecords[i].GetFilename() == nullptr || mHeaderRecords[i].GetFilename()[0] == '\0')
- {
- mHeaderRecords[i].mOffset = 0;
- }
- else
- {
- mHeaderRecords[i].mOffset = offset;
- offset += mDataRecords[i]->GetSize();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement