TreFile: fix compressed file size of last file
This commit is contained in:
20
TreFile.cc
20
TreFile.cc
@@ -95,6 +95,20 @@ TreFile::TreFile(char const* base, size_t length)
|
|||||||
table3_.emplace_back(dataPtr, length, length, flags);
|
table3_.emplace_back(dataPtr, length, length, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fixup last file clength
|
||||||
|
{
|
||||||
|
uint32_t lastPtr, lastLen;
|
||||||
|
uint8_t lastFlags;
|
||||||
|
std::tie(lastPtr, std::ignore, lastLen, lastFlags) = table3_.back();
|
||||||
|
if (lastPtr+lastLen > length_) {
|
||||||
|
if (lastFlags&0x80)
|
||||||
|
std::get<2>(table3_.back()) = length_ - lastPtr;
|
||||||
|
else
|
||||||
|
fprintf(stderr, "Overrun? %u %u (%hhu) -> %lu\n",lastPtr, lastLen, lastFlags, length_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Read Table 2
|
// Read Table 2
|
||||||
std::map<size_t, uint32_t> table2Pos;
|
std::map<size_t, uint32_t> table2Pos;
|
||||||
|
|
||||||
@@ -268,17 +282,19 @@ void TreFile::printStructure()
|
|||||||
|
|
||||||
printf("Files by CRC:\n");
|
printf("Files by CRC:\n");
|
||||||
for(auto const& ent : table1_) {
|
for(auto const& ent : table1_) {
|
||||||
printf("\t%.8x -> (ofs %.8x, len %.8x, flags %.2hhx)\n", ent.first,
|
printf("\t%.8x -> (ofs %.8x, len %.8x, clen %.8x, flags %.2hhx)\n", ent.first,
|
||||||
std::get<0>(table3_[ent.second]),
|
std::get<0>(table3_[ent.second]),
|
||||||
std::get<1>(table3_[ent.second]),
|
std::get<1>(table3_[ent.second]),
|
||||||
|
std::get<2>(table3_[ent.second]),
|
||||||
std::get<3>(table3_[ent.second]));
|
std::get<3>(table3_[ent.second]));
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Files by Name:\n");
|
printf("Files by Name:\n");
|
||||||
for(auto const& ent : table2_) {
|
for(auto const& ent : table2_) {
|
||||||
printf("\t%s -> (ofs %.8x, len %.8x, flags %.2hhx)\n", ent.first.c_str(),
|
printf("\t%s -> (ofs %.8x, len %.8x, clen %.8x, flags %.2hhx)\n", ent.first.c_str(),
|
||||||
std::get<0>(table3_[ent.second]),
|
std::get<0>(table3_[ent.second]),
|
||||||
std::get<1>(table3_[ent.second]),
|
std::get<1>(table3_[ent.second]),
|
||||||
|
std::get<2>(table3_[ent.second]),
|
||||||
std::get<3>(table3_[ent.second]));
|
std::get<3>(table3_[ent.second]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user