Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion include/libweaver/interleaf.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class Interleaf : public Core
{
IncludeData = 1,
IncludeInfo = 2,
ObjectsOnly = 4
ObjectsOnly = 4,
HeaderOnly = 8
};

LIBWEAVER_EXPORT Interleaf();
Expand All @@ -50,6 +51,8 @@ class Interleaf : public Core
Error Read(FileBase *is, int flags = IncludeData | IncludeInfo);
Error Write(FileBase *os) const;

LIBWEAVER_EXPORT Error ReadObject(FileBase *f, uint32_t slot);

Info *GetInformation() { return &m_Info; }

private:
Expand All @@ -75,6 +78,8 @@ class Interleaf : public Core
std::map<uint32_t, Object*> m_ObjectOffsetTable;
std::map<uint32_t, Object*> m_ObjectIDTable;

std::vector<uint32_t> m_SlotOffsets;

uint32_t m_JoiningProgress;
uint32_t m_JoiningSize;

Expand Down
23 changes: 23 additions & 0 deletions lib/interleaf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void Interleaf::Clear()
m_JoiningSize = 0;
m_ObjectOffsetTable.clear();
m_ObjectIDTable.clear();
m_SlotOffsets.clear();
DeleteChildren();
}

Expand Down Expand Up @@ -125,6 +126,7 @@ Interleaf::Error Interleaf::ReadChunk(Core *parent, FileBase *f, Info *info)
if (choffset) {
m_ObjectOffsetTable[choffset] = o;
}
m_SlotOffsets.push_back(choffset);
desc << std::endl << i << ": 0x" << std::hex << choffset;
}
break;
Expand Down Expand Up @@ -305,6 +307,13 @@ Interleaf::Error Interleaf::ReadChunk(Core *parent, FileBase *f, Info *info)
}
}

// Stop after reading just the header (MxHd + MxOf)
if (m_readFlags & HeaderOnly) {
if (static_cast<RIFF::Type>(id) == RIFF::MxOf) {
f->seek(0, FileBase::SeekEnd);
}
}

return ERROR_SUCCESS;
}

Expand Down Expand Up @@ -370,6 +379,20 @@ Object *Interleaf::ReadObject(FileBase *f, Object *o, std::ostream &desc)
return o;
}

Interleaf::Error Interleaf::ReadObject(FileBase *f, uint32_t slot)
{
if (slot >= m_SlotOffsets.size() || m_SlotOffsets[slot] == 0) {
return ERROR_INVALID_INPUT;
}

m_JoiningProgress = 0;
m_JoiningSize = 0;
m_readFlags = IncludeData;

f->seek(m_SlotOffsets[slot], FileBase::SeekStart);
return ReadChunk(this, f, NULL);
}

Interleaf::Error Interleaf::Read(FileBase *f, int flags)
{
Clear();
Expand Down
Loading