hpkg format: user big endian for chunk sizes

This commit is contained in:
Ingo Weinhold
2013-05-25 01:55:36 +02:00
parent a98dd49a6b
commit e2f30519ab
2 changed files with 5 additions and 3 deletions
@@ -13,6 +13,7 @@
#include <algorithm>
#include <new>
#include <ByteOrder.h>
#include <package/hpkg/DataOutput.h>
#include <package/hpkg/ErrorOutput.h>
@@ -62,7 +63,7 @@ PackageFileHeapAccessorBase::OffsetArray::InitChunksOffsets(
uint64 offset = (*this)[baseIndex];
for (size_t i = 0; i < chunkCount; i++) {
offset += (uint64)chunkSizes[i] + 1;
offset += (uint64)B_BENDIAN_TO_HOST_INT16(chunkSizes[i]) + 1;
// the stored value is chunkSize - 1
size_t index = baseIndex + i + 1;
// (baseIndex + i) is the index of the chunk whose size is stored in
@@ -11,6 +11,7 @@
#include <algorithm>
#include <new>
#include <ByteOrder.h>
#include <List.h>
#include <package/hpkg/ErrorOutput.h>
#include <package/hpkg/HPKGDefs.h>
@@ -439,8 +440,8 @@ PackageFileHeapWriter::Finish()
for (ssize_t i = 0; i < toWrite; i++, offsetIndex++) {
// store chunkSize - 1, so it fits 16 bit (chunks cannot be empty)
buffer[i] = uint16(fOffsets[offsetIndex] - fOffsets[offsetIndex - 1]
- 1);
buffer[i] = B_HOST_TO_BENDIAN_INT16(
uint16(fOffsets[offsetIndex] - fOffsets[offsetIndex - 1] - 1));
}
error = _WriteDataUncompressed(buffer, toWrite * 2);