22 #include "ciff/heap.hpp"
23 #include "ciffcontainer.hpp"
32 m_container(_container),
35 LOGDBG2(
"Heap @ %lld length = %lld\n", (
long long int)start, (
long long int)m_length);
40 if (m_records.size() == 0) {
47 bool Heap::_loadRecords()
49 auto file = m_container->file();
50 auto endian = m_container->endian();
51 file->seek(m_start + m_length - 4, SEEK_SET);
53 auto result = m_container->
readInt32(file, endian);
56 int32_t record_offset = result.value();
59 file->seek(m_start + record_offset, SEEK_SET);
60 auto result16 = m_container->
readInt16(file, endian);
61 if (result16.empty()) {
62 LOGDBG1(
"read numRecords failed\n");
65 int16_t numRecords = result16.value();
66 LOGDBG2(
"numRecords %d\n", numRecords);
68 for (int16_t i = 0; i < numRecords; i++) {
71 m_records.insert(std::make_pair(TAGCODE(entry.
typeCode), entry));
82 auto file = container->file();
91 container->setEndian(
endian);
98 ret = (file->read(
type, 4) == 4);
101 ret = (file->read(
subType, 4) == 4);
Heap(off_t start, off_t length, const CIFFContainer *container)
Construct a heap from a location in the container.
RecordEntries & records()
Return the records from the heap. Load them as needed.
A record entry from a CIFF Heap.
bool readFrom(const CIFFContainer *container)
Option< uint32_t > readUInt32(const IO::Stream::Ptr &f, EndianType endian) const
Read an uint32 following the m_endian set.
Option< int32_t > readInt32(const IO::Stream::Ptr &f, EndianType endian) const
Read an int32 following the m_endian set.
Option< int16_t > readInt16(const IO::Stream::Ptr &f, EndianType endian) const
Read an int16 following the m_endian set.
std::map< uint16_t, RecordEntry > RecordEntries
Global namespace for libopenraw.