70 |
} |
} |
71 |
|
|
72 |
Chunk::~Chunk() { |
Chunk::~Chunk() { |
73 |
|
if (CurrentChunkSize != NewChunkSize) pFile->UnlogResized(this); |
74 |
if (pChunkData) delete[] pChunkData; |
if (pChunkData) delete[] pChunkData; |
75 |
} |
} |
76 |
|
|
1516 |
// first we sum up all positive chunk size changes (and skip all negative ones) |
// first we sum up all positive chunk size changes (and skip all negative ones) |
1517 |
unsigned long ulPositiveSizeDiff = 0; |
unsigned long ulPositiveSizeDiff = 0; |
1518 |
for (ChunkList::iterator iter = ResizedChunks.begin(), end = ResizedChunks.end(); iter != end; ++iter) { |
for (ChunkList::iterator iter = ResizedChunks.begin(), end = ResizedChunks.end(); iter != end; ++iter) { |
1519 |
if ((*iter)->GetNewSize() == 0) throw Exception("There is at least one empty chunk (zero size)"); |
if ((*iter)->GetNewSize() == 0) { |
1520 |
|
// just to make the exception message a bit more verbose: resolve the chunk's path |
1521 |
|
String sChunkPath; |
1522 |
|
for (Chunk* pChunk = *iter; pChunk; pChunk = pChunk->GetParent()) { |
1523 |
|
if (pChunk->GetChunkID() == CHUNK_ID_LIST) { |
1524 |
|
List* pList = (List*) pChunk; |
1525 |
|
sChunkPath = "->'" + pList->GetListTypeString() + "'" + sChunkPath; |
1526 |
|
} else { |
1527 |
|
sChunkPath = "->'" + pChunk->GetChunkIDString() + "'" + sChunkPath; |
1528 |
|
} |
1529 |
|
} |
1530 |
|
throw Exception("There is at least one empty chunk (zero size): " + sChunkPath); |
1531 |
|
} |
1532 |
if ((*iter)->GetNewSize() + 1L > (*iter)->GetSize()) { |
if ((*iter)->GetNewSize() + 1L > (*iter)->GetSize()) { |
1533 |
unsigned long ulDiff = (*iter)->GetNewSize() - (*iter)->GetSize() + 1L; // +1 in case we have to add a pad byte |
unsigned long ulDiff = (*iter)->GetNewSize() - (*iter)->GetSize() + 1L; // +1 in case we have to add a pad byte |
1534 |
ulPositiveSizeDiff += ulDiff; |
ulPositiveSizeDiff += ulDiff; |
1689 |
ResizedChunks.push_back(pResizedChunk); |
ResizedChunks.push_back(pResizedChunk); |
1690 |
} |
} |
1691 |
|
|
1692 |
|
void File::UnlogResized(Chunk* pResizedChunk) { |
1693 |
|
ResizedChunks.remove(pResizedChunk); |
1694 |
|
} |
1695 |
|
|
1696 |
unsigned long File::GetFileSize() { |
unsigned long File::GetFileSize() { |
1697 |
return __GetFileSize(hFileRead); |
return __GetFileSize(hFileRead); |
1698 |
} |
} |