hpkg format: user big endian for chunk sizes
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user