mirror of
https://github.com/AxioDL/nod.git
synced 2025-12-08 21:17:51 +00:00
FST building/traversal in place
This commit is contained in:
@@ -8,12 +8,39 @@ DiscBase::DiscBase(std::unique_ptr<IDiscIO>&& dio)
|
||||
{
|
||||
}
|
||||
|
||||
void DiscBase::IPartition::parseFST()
|
||||
void DiscBase::IPartition::parseFST(IPartReadStream& s)
|
||||
{
|
||||
char buf[1024];
|
||||
std::unique_ptr<IPartReadStream> s = beginReadStream();
|
||||
s->read(buf, 1024);
|
||||
printf("");
|
||||
std::unique_ptr<uint8_t[]> fst(new uint8_t[m_fstSz]);
|
||||
s.seek(m_fstOff);
|
||||
s.read(fst.get(), m_fstSz);
|
||||
|
||||
const FSTNode* nodes = (FSTNode*)fst.get();
|
||||
|
||||
/* Root node indicates the count of all contained nodes */
|
||||
uint32_t nodeCount = nodes[0].getLength();
|
||||
const char* names = (char*)fst.get() + 12 * nodeCount;
|
||||
m_nodes.clear();
|
||||
m_nodes.reserve(nodeCount);
|
||||
|
||||
/* Construct nodes */
|
||||
for (uint32_t n=0 ; n<nodeCount ; ++n)
|
||||
{
|
||||
const FSTNode& node = nodes[n];
|
||||
m_nodes.emplace_back(*this, node, n ? names + node.getNameOffset() : "<root>");
|
||||
}
|
||||
|
||||
/* Setup dir-child iterators */
|
||||
for (std::vector<Node>::iterator it=m_nodes.begin();
|
||||
it != m_nodes.end();
|
||||
++it)
|
||||
{
|
||||
Node& node = *it;
|
||||
if (node.m_kind == Node::NODE_DIRECTORY)
|
||||
{
|
||||
node.m_childrenBegin = it + 1;
|
||||
node.m_childrenEnd = m_nodes.begin() + node.m_discLength;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user