mirror of
https://github.com/AxioDL/nod.git
synced 2025-07-03 03:36:07 +00:00
Huge compile performance refactor
This commit is contained in:
parent
34de6276b0
commit
a557f86974
@ -1,5 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include "logvisor/logvisor.hpp"
|
#include "logvisor/logvisor.hpp"
|
||||||
#include "nod/nod.hpp"
|
#include "nod/nod.hpp"
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "Util.hpp"
|
#include "Util.hpp"
|
||||||
#include "IDiscIO.hpp"
|
#include "IDiscIO.hpp"
|
||||||
@ -186,27 +186,8 @@ struct BI2Header
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct ExtractionContext;
|
struct ExtractionContext;
|
||||||
class DiscBase
|
class IPartition;
|
||||||
{
|
class DiscBase;
|
||||||
public:
|
|
||||||
virtual ~DiscBase() = default;
|
|
||||||
|
|
||||||
class IPartition
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~IPartition() = default;
|
|
||||||
struct DOLHeader
|
|
||||||
{
|
|
||||||
uint32_t textOff[7];
|
|
||||||
uint32_t dataOff[11];
|
|
||||||
uint32_t textStarts[7];
|
|
||||||
uint32_t dataStarts[11];
|
|
||||||
uint32_t textSizes[7];
|
|
||||||
uint32_t dataSizes[11];
|
|
||||||
uint32_t bssStart;
|
|
||||||
uint32_t bssSize;
|
|
||||||
uint32_t entryPoint;
|
|
||||||
};
|
|
||||||
|
|
||||||
class Node
|
class Node
|
||||||
{
|
{
|
||||||
@ -229,35 +210,12 @@ public:
|
|||||||
std::vector<Node>::iterator m_childrenEnd;
|
std::vector<Node>::iterator m_childrenEnd;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Node(const IPartition& parent, const FSTNode& node, std::string_view name)
|
Node(const IPartition& parent, const FSTNode& node, std::string_view name);
|
||||||
: m_parent(parent),
|
|
||||||
m_kind(node.isDir() ? Kind::Directory : Kind::File),
|
|
||||||
m_discOffset(parent.normalizeOffset(node.getOffset())),
|
|
||||||
m_discLength(node.getLength()),
|
|
||||||
m_name(name) {}
|
|
||||||
inline Kind getKind() const {return m_kind;}
|
inline Kind getKind() const {return m_kind;}
|
||||||
inline std::string_view getName() const {return m_name;}
|
inline std::string_view getName() const {return m_name;}
|
||||||
inline uint64_t size() const {return m_discLength;}
|
inline uint64_t size() const {return m_discLength;}
|
||||||
std::unique_ptr<IPartReadStream> beginReadStream(uint64_t offset=0) const
|
std::unique_ptr<IPartReadStream> beginReadStream(uint64_t offset=0) const;
|
||||||
{
|
std::unique_ptr<uint8_t[]> getBuf() const;
|
||||||
if (m_kind != Kind::File)
|
|
||||||
{
|
|
||||||
LogModule.report(logvisor::Error, "unable to stream a non-file %s", m_name.c_str());
|
|
||||||
return std::unique_ptr<IPartReadStream>();
|
|
||||||
}
|
|
||||||
return m_parent.beginReadStream(m_discOffset + offset);
|
|
||||||
}
|
|
||||||
std::unique_ptr<uint8_t[]> getBuf() const
|
|
||||||
{
|
|
||||||
if (m_kind != Kind::File)
|
|
||||||
{
|
|
||||||
LogModule.report(logvisor::Error, "unable to buffer a non-file %s", m_name.c_str());
|
|
||||||
return std::unique_ptr<uint8_t[]>();
|
|
||||||
}
|
|
||||||
uint8_t* buf = new uint8_t[m_discLength];
|
|
||||||
beginReadStream()->read(buf, m_discLength);
|
|
||||||
return std::unique_ptr<uint8_t[]>(buf);
|
|
||||||
}
|
|
||||||
inline std::vector<Node>::iterator rawBegin() const {return m_childrenBegin;}
|
inline std::vector<Node>::iterator rawBegin() const {return m_childrenBegin;}
|
||||||
inline std::vector<Node>::iterator rawEnd() const {return m_childrenEnd;}
|
inline std::vector<Node>::iterator rawEnd() const {return m_childrenEnd;}
|
||||||
|
|
||||||
@ -265,8 +223,7 @@ public:
|
|||||||
{
|
{
|
||||||
friend class Node;
|
friend class Node;
|
||||||
std::vector<Node>::iterator m_it;
|
std::vector<Node>::iterator m_it;
|
||||||
DirectoryIterator(const std::vector<Node>::iterator& it)
|
DirectoryIterator(const std::vector<Node>::iterator& it) : m_it(it) {}
|
||||||
: m_it(it) {}
|
|
||||||
public:
|
public:
|
||||||
using iterator_category = std::forward_iterator_tag;
|
using iterator_category = std::forward_iterator_tag;
|
||||||
using value_type = Node;
|
using value_type = Node;
|
||||||
@ -306,6 +263,24 @@ public:
|
|||||||
|
|
||||||
bool extractToDirectory(SystemStringView basePath, const ExtractionContext& ctx) const;
|
bool extractToDirectory(SystemStringView basePath, const ExtractionContext& ctx) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class IPartition
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IPartition() = default;
|
||||||
|
struct DOLHeader
|
||||||
|
{
|
||||||
|
uint32_t textOff[7];
|
||||||
|
uint32_t dataOff[11];
|
||||||
|
uint32_t textStarts[7];
|
||||||
|
uint32_t dataStarts[11];
|
||||||
|
uint32_t textSizes[7];
|
||||||
|
uint32_t dataSizes[11];
|
||||||
|
uint32_t bssStart;
|
||||||
|
uint32_t bssSize;
|
||||||
|
uint32_t entryPoint;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Header m_header;
|
Header m_header;
|
||||||
BI2Header m_bi2Header;
|
BI2Header m_bi2Header;
|
||||||
@ -389,6 +364,10 @@ public:
|
|||||||
bool extractSysFiles(SystemStringView path, const ExtractionContext& ctx) const;
|
bool extractSysFiles(SystemStringView path, const ExtractionContext& ctx) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DiscBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~DiscBase() = default;
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<IDiscIO> m_discIO;
|
std::unique_ptr<IDiscIO> m_discIO;
|
||||||
Header m_header;
|
Header m_header;
|
||||||
@ -454,16 +433,16 @@ public:
|
|||||||
std::function<void(void)> incParents,
|
std::function<void(void)> incParents,
|
||||||
size_t parentDirIdx);
|
size_t parentDirIdx);
|
||||||
|
|
||||||
void recursiveMergeNodesPre(const DiscBase::IPartition::Node* nodeIn, SystemStringView dirIn);
|
void recursiveMergeNodesPre(const Node* nodeIn, SystemStringView dirIn);
|
||||||
bool recursiveMergeNodes(IPartWriteStream& ws, bool system,
|
bool recursiveMergeNodes(IPartWriteStream& ws, bool system,
|
||||||
const DiscBase::IPartition::Node* nodeIn, SystemStringView dirIn,
|
const Node* nodeIn, SystemStringView dirIn,
|
||||||
SystemStringView keyPath);
|
SystemStringView keyPath);
|
||||||
bool recursiveMergeFST(const DiscBase::IPartition::Node* nodeIn,
|
bool recursiveMergeFST(const Node* nodeIn,
|
||||||
SystemStringView dirIn, std::function<void(void)> incParents,
|
SystemStringView dirIn, std::function<void(void)> incParents,
|
||||||
SystemStringView keyPath);
|
SystemStringView keyPath);
|
||||||
|
|
||||||
static bool RecursiveCalculateTotalSize(uint64_t& totalSz,
|
static bool RecursiveCalculateTotalSize(uint64_t& totalSz,
|
||||||
const DiscBase::IPartition::Node* nodeIn,
|
const Node* nodeIn,
|
||||||
SystemStringView dirIn);
|
SystemStringView dirIn);
|
||||||
|
|
||||||
void addBuildName(SystemStringView str)
|
void addBuildName(SystemStringView str)
|
||||||
@ -485,8 +464,8 @@ public:
|
|||||||
virtual std::unique_ptr<IPartWriteStream> beginWriteStream(uint64_t offset)=0;
|
virtual std::unique_ptr<IPartWriteStream> beginWriteStream(uint64_t offset)=0;
|
||||||
bool buildFromDirectory(IPartWriteStream& ws, SystemStringView dirIn);
|
bool buildFromDirectory(IPartWriteStream& ws, SystemStringView dirIn);
|
||||||
static uint64_t CalculateTotalSizeBuild(SystemStringView dirIn, PartitionKind kind, bool isWii);
|
static uint64_t CalculateTotalSizeBuild(SystemStringView dirIn, PartitionKind kind, bool isWii);
|
||||||
bool mergeFromDirectory(IPartWriteStream& ws, const DiscBase::IPartition* partIn, SystemStringView dirIn);
|
bool mergeFromDirectory(IPartWriteStream& ws, const IPartition* partIn, SystemStringView dirIn);
|
||||||
static uint64_t CalculateTotalSizeMerge(const DiscBase::IPartition* partIn, SystemStringView dirIn);
|
static uint64_t CalculateTotalSizeMerge(const IPartition* partIn, SystemStringView dirIn);
|
||||||
};
|
};
|
||||||
protected:
|
protected:
|
||||||
SystemString m_outPath;
|
SystemString m_outPath;
|
||||||
@ -523,9 +502,6 @@ public:
|
|||||||
IFileIO& getFileIO() { return *m_fileIO; }
|
IFileIO& getFileIO() { return *m_fileIO; }
|
||||||
};
|
};
|
||||||
|
|
||||||
using Partition = DiscBase::IPartition;
|
|
||||||
using Node = Partition::Node;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // __NOD_DISC_BASE__
|
#endif // __NOD_DISC_BASE__
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#define __NOD_IDISC_IO__
|
#define __NOD_IDISC_IO__
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
|
|
||||||
#if NOD_ATHENA
|
#if NOD_ATHENA
|
||||||
#include <athena/IStreamReader.hpp>
|
#include <athena/IStreamReader.hpp>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include "IDiscIO.hpp"
|
#include "IDiscIO.hpp"
|
||||||
#include "Util.hpp"
|
#include "Util.hpp"
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <sys/file.h>
|
#include <sys/file.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/statvfs.h>
|
#include <sys/statvfs.h>
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef __AES_HPP__
|
#ifndef __AES_HPP__
|
||||||
#define __AES_HPP__
|
#define __AES_HPP__
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace nod
|
namespace nod
|
||||||
|
107
lib/DiscBase.cpp
107
lib/DiscBase.cpp
@ -3,8 +3,8 @@
|
|||||||
#include "nod/DirectoryEnumerator.hpp"
|
#include "nod/DirectoryEnumerator.hpp"
|
||||||
#include "nod/nod.hpp"
|
#include "nod/nod.hpp"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <errno.h>
|
#include <cerrno>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -53,7 +53,7 @@ const SystemChar* getKindString(PartitionKind kind)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiscBase::IPartition::parseFST(IPartReadStream& s)
|
void IPartition::parseFST(IPartReadStream& s)
|
||||||
{
|
{
|
||||||
std::unique_ptr<uint8_t[]> fst(new uint8_t[m_fstSz]);
|
std::unique_ptr<uint8_t[]> fst(new uint8_t[m_fstSz]);
|
||||||
s.seek(m_fstOff);
|
s.seek(m_fstOff);
|
||||||
@ -88,7 +88,7 @@ void DiscBase::IPartition::parseFST(IPartReadStream& s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiscBase::IPartition::parseDOL(IPartReadStream& s)
|
void IPartition::parseDOL(IPartReadStream& s)
|
||||||
{
|
{
|
||||||
/* Read Dol header */
|
/* Read Dol header */
|
||||||
DOLHeader dolHeader;
|
DOLHeader dolHeader;
|
||||||
@ -104,8 +104,36 @@ void DiscBase::IPartition::parseDOL(IPartReadStream& s)
|
|||||||
m_dolSz = dolSize;
|
m_dolSz = dolSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiscBase::IPartition::Node::extractToDirectory(SystemStringView basePath,
|
Node::Node(const IPartition& parent, const FSTNode& node, std::string_view name)
|
||||||
const ExtractionContext& ctx) const
|
: m_parent(parent),
|
||||||
|
m_kind(node.isDir() ? Kind::Directory : Kind::File),
|
||||||
|
m_discOffset(parent.normalizeOffset(node.getOffset())),
|
||||||
|
m_discLength(node.getLength()),
|
||||||
|
m_name(name) {}
|
||||||
|
|
||||||
|
std::unique_ptr<IPartReadStream> Node::beginReadStream(uint64_t offset) const
|
||||||
|
{
|
||||||
|
if (m_kind != Kind::File)
|
||||||
|
{
|
||||||
|
LogModule.report(logvisor::Error, "unable to stream a non-file %s", m_name.c_str());
|
||||||
|
return std::unique_ptr<IPartReadStream>();
|
||||||
|
}
|
||||||
|
return m_parent.beginReadStream(m_discOffset + offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<uint8_t[]> Node::getBuf() const
|
||||||
|
{
|
||||||
|
if (m_kind != Kind::File)
|
||||||
|
{
|
||||||
|
LogModule.report(logvisor::Error, "unable to buffer a non-file %s", m_name.c_str());
|
||||||
|
return std::unique_ptr<uint8_t[]>();
|
||||||
|
}
|
||||||
|
uint8_t* buf = new uint8_t[m_discLength];
|
||||||
|
beginReadStream()->read(buf, m_discLength);
|
||||||
|
return std::unique_ptr<uint8_t[]>(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Node::extractToDirectory(SystemStringView basePath, const ExtractionContext& ctx) const
|
||||||
{
|
{
|
||||||
SystemStringConv nameView(getName());
|
SystemStringConv nameView(getName());
|
||||||
SystemString path = SystemString(basePath) + _S('/') + nameView.sys_str().data();
|
SystemString path = SystemString(basePath) + _S('/') + nameView.sys_str().data();
|
||||||
@ -148,8 +176,7 @@ bool DiscBase::IPartition::Node::extractToDirectory(SystemStringView basePath,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiscBase::IPartition::extractToDirectory(SystemStringView path,
|
bool IPartition::extractToDirectory(SystemStringView path, const ExtractionContext& ctx)
|
||||||
const ExtractionContext& ctx)
|
|
||||||
{
|
{
|
||||||
m_curNodeIdx = 0;
|
m_curNodeIdx = 0;
|
||||||
if (Mkdir(path.data(), 0755) && errno != EEXIST)
|
if (Mkdir(path.data(), 0755) && errno != EEXIST)
|
||||||
@ -190,7 +217,7 @@ bool DiscBase::IPartition::extractToDirectory(SystemStringView path,
|
|||||||
return m_nodes[0].extractToDirectory(fsPath, ctx);
|
return m_nodes[0].extractToDirectory(fsPath, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiscBase::IPartition::extractSysFiles(SystemStringView basePath, const ExtractionContext& ctx) const
|
bool IPartition::extractSysFiles(SystemStringView basePath, const ExtractionContext& ctx) const
|
||||||
{
|
{
|
||||||
SystemString basePathStr(basePath);
|
SystemString basePathStr(basePath);
|
||||||
if (Mkdir((basePathStr + _S("/sys")).c_str(), 0755) && errno != EEXIST)
|
if (Mkdir((basePathStr + _S("/sys")).c_str(), 0755) && errno != EEXIST)
|
||||||
@ -403,21 +430,20 @@ bool DiscBuilderBase::PartitionBuilderBase::recursiveBuildFST(SystemStringView f
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodesPre(const DiscBase::IPartition::Node* nodeIn,
|
void DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodesPre(const Node* nodeIn, SystemStringView dirIn)
|
||||||
SystemStringView dirIn)
|
|
||||||
{
|
{
|
||||||
/* Build map of existing nodes to write-through later */
|
/* Build map of existing nodes to write-through later */
|
||||||
std::unordered_map<std::string, const Partition::Node*> fileNodes;
|
std::unordered_map<std::string, const Node*> fileNodes;
|
||||||
std::unordered_map<std::string, const Partition::Node*> dirNodes;
|
std::unordered_map<std::string, const Node*> dirNodes;
|
||||||
if (nodeIn)
|
if (nodeIn)
|
||||||
{
|
{
|
||||||
fileNodes.reserve(nodeIn->size());
|
fileNodes.reserve(nodeIn->size());
|
||||||
dirNodes.reserve(nodeIn->size());
|
dirNodes.reserve(nodeIn->size());
|
||||||
for (const Partition::Node& ch : *nodeIn)
|
for (const Node& ch : *nodeIn)
|
||||||
{
|
{
|
||||||
if (ch.getKind() == Partition::Node::Kind::File)
|
if (ch.getKind() == Node::Kind::File)
|
||||||
fileNodes.insert(std::make_pair(ch.getName(), &ch));
|
fileNodes.insert(std::make_pair(ch.getName(), &ch));
|
||||||
else if (ch.getKind() == Partition::Node::Kind::Directory)
|
else if (ch.getKind() == Node::Kind::Directory)
|
||||||
dirNodes.insert(std::make_pair(ch.getName(), &ch));
|
dirNodes.insert(std::make_pair(ch.getName(), &ch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -463,22 +489,22 @@ void DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodesPre(const DiscBas
|
|||||||
|
|
||||||
bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodes(IPartWriteStream& ws,
|
bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodes(IPartWriteStream& ws,
|
||||||
bool system,
|
bool system,
|
||||||
const DiscBase::IPartition::Node* nodeIn,
|
const Node* nodeIn,
|
||||||
SystemStringView dirIn,
|
SystemStringView dirIn,
|
||||||
SystemStringView keyPath)
|
SystemStringView keyPath)
|
||||||
{
|
{
|
||||||
/* Build map of existing nodes to write-through later */
|
/* Build map of existing nodes to write-through later */
|
||||||
std::unordered_map<std::string, const Partition::Node*> fileNodes;
|
std::unordered_map<std::string, const Node*> fileNodes;
|
||||||
std::unordered_map<std::string, const Partition::Node*> dirNodes;
|
std::unordered_map<std::string, const Node*> dirNodes;
|
||||||
if (nodeIn)
|
if (nodeIn)
|
||||||
{
|
{
|
||||||
fileNodes.reserve(nodeIn->size());
|
fileNodes.reserve(nodeIn->size());
|
||||||
dirNodes.reserve(nodeIn->size());
|
dirNodes.reserve(nodeIn->size());
|
||||||
for (const Partition::Node& ch : *nodeIn)
|
for (const Node& ch : *nodeIn)
|
||||||
{
|
{
|
||||||
if (ch.getKind() == Partition::Node::Kind::File)
|
if (ch.getKind() == Node::Kind::File)
|
||||||
fileNodes.insert(std::make_pair(ch.getName(), &ch));
|
fileNodes.insert(std::make_pair(ch.getName(), &ch));
|
||||||
else if (ch.getKind() == Partition::Node::Kind::Directory)
|
else if (ch.getKind() == Node::Kind::Directory)
|
||||||
dirNodes.insert(std::make_pair(ch.getName(), &ch));
|
dirNodes.insert(std::make_pair(ch.getName(), &ch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -565,7 +591,7 @@ bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodes(IPartWriteStream
|
|||||||
/* Write-through remaining file nodes */
|
/* Write-through remaining file nodes */
|
||||||
for (const auto& p : fileNodes)
|
for (const auto& p : fileNodes)
|
||||||
{
|
{
|
||||||
const Partition::Node& ch = *p.second;
|
const Node& ch = *p.second;
|
||||||
SystemStringConv sysName(ch.getName());
|
SystemStringConv sysName(ch.getName());
|
||||||
SystemString chKeyPath = SystemString(keyPath) + _S('/') + sysName.c_str();
|
SystemString chKeyPath = SystemString(keyPath) + _S('/') + sysName.c_str();
|
||||||
|
|
||||||
@ -615,23 +641,23 @@ bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeNodes(IPartWriteStream
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeFST(const Partition::Node* nodeIn,
|
bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeFST(const Node* nodeIn,
|
||||||
SystemStringView dirIn,
|
SystemStringView dirIn,
|
||||||
std::function<void(void)> incParents,
|
std::function<void(void)> incParents,
|
||||||
SystemStringView keyPath)
|
SystemStringView keyPath)
|
||||||
{
|
{
|
||||||
/* Build map of existing nodes to write-through later */
|
/* Build map of existing nodes to write-through later */
|
||||||
std::unordered_map<std::string, const Partition::Node*> fileNodes;
|
std::unordered_map<std::string, const Node*> fileNodes;
|
||||||
std::unordered_map<std::string, const Partition::Node*> dirNodes;
|
std::unordered_map<std::string, const Node*> dirNodes;
|
||||||
if (nodeIn)
|
if (nodeIn)
|
||||||
{
|
{
|
||||||
fileNodes.reserve(nodeIn->size());
|
fileNodes.reserve(nodeIn->size());
|
||||||
dirNodes.reserve(nodeIn->size());
|
dirNodes.reserve(nodeIn->size());
|
||||||
for (const Partition::Node& ch : *nodeIn)
|
for (const Node& ch : *nodeIn)
|
||||||
{
|
{
|
||||||
if (ch.getKind() == Partition::Node::Kind::File)
|
if (ch.getKind() == Node::Kind::File)
|
||||||
fileNodes.insert(std::make_pair(ch.getName(), &ch));
|
fileNodes.insert(std::make_pair(ch.getName(), &ch));
|
||||||
else if (ch.getKind() == Partition::Node::Kind::Directory)
|
else if (ch.getKind() == Node::Kind::Directory)
|
||||||
dirNodes.insert(std::make_pair(ch.getName(), &ch));
|
dirNodes.insert(std::make_pair(ch.getName(), &ch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -701,7 +727,7 @@ bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeFST(const Partition::N
|
|||||||
/* Write-through remaining file nodes */
|
/* Write-through remaining file nodes */
|
||||||
for (const auto& p : fileNodes)
|
for (const auto& p : fileNodes)
|
||||||
{
|
{
|
||||||
const Partition::Node& ch = *p.second;
|
const Node& ch = *p.second;
|
||||||
SystemStringConv sysName(ch.getName());
|
SystemStringConv sysName(ch.getName());
|
||||||
SystemString chKeyPath = SystemString(keyPath) + _S('/') + sysName.sys_str().data();
|
SystemString chKeyPath = SystemString(keyPath) + _S('/') + sysName.sys_str().data();
|
||||||
|
|
||||||
@ -714,23 +740,22 @@ bool DiscBuilderBase::PartitionBuilderBase::recursiveMergeFST(const Partition::N
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DiscBuilderBase::PartitionBuilderBase::RecursiveCalculateTotalSize(
|
bool DiscBuilderBase::PartitionBuilderBase::RecursiveCalculateTotalSize(uint64_t& totalSz,
|
||||||
uint64_t& totalSz,
|
const Node* nodeIn,
|
||||||
const DiscBase::IPartition::Node* nodeIn,
|
|
||||||
SystemStringView dirIn)
|
SystemStringView dirIn)
|
||||||
{
|
{
|
||||||
/* Build map of existing nodes to write-through later */
|
/* Build map of existing nodes to write-through later */
|
||||||
std::unordered_map<std::string, const Partition::Node*> fileNodes;
|
std::unordered_map<std::string, const Node*> fileNodes;
|
||||||
std::unordered_map<std::string, const Partition::Node*> dirNodes;
|
std::unordered_map<std::string, const Node*> dirNodes;
|
||||||
if (nodeIn)
|
if (nodeIn)
|
||||||
{
|
{
|
||||||
fileNodes.reserve(nodeIn->size());
|
fileNodes.reserve(nodeIn->size());
|
||||||
dirNodes.reserve(nodeIn->size());
|
dirNodes.reserve(nodeIn->size());
|
||||||
for (const Partition::Node& ch : *nodeIn)
|
for (const Node& ch : *nodeIn)
|
||||||
{
|
{
|
||||||
if (ch.getKind() == Partition::Node::Kind::File)
|
if (ch.getKind() == Node::Kind::File)
|
||||||
fileNodes.insert(std::make_pair(ch.getName(), &ch));
|
fileNodes.insert(std::make_pair(ch.getName(), &ch));
|
||||||
else if (ch.getKind() == Partition::Node::Kind::Directory)
|
else if (ch.getKind() == Node::Kind::Directory)
|
||||||
dirNodes.insert(std::make_pair(ch.getName(), &ch));
|
dirNodes.insert(std::make_pair(ch.getName(), &ch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -776,7 +801,7 @@ bool DiscBuilderBase::PartitionBuilderBase::RecursiveCalculateTotalSize(
|
|||||||
/* Write-through remaining file nodes */
|
/* Write-through remaining file nodes */
|
||||||
for (const auto& p : fileNodes)
|
for (const auto& p : fileNodes)
|
||||||
{
|
{
|
||||||
const Partition::Node& ch = *p.second;
|
const Node& ch = *p.second;
|
||||||
totalSz += ROUND_UP_32(ch.size());
|
totalSz += ROUND_UP_32(ch.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -867,7 +892,7 @@ uint64_t DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeBuild(SystemSt
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool DiscBuilderBase::PartitionBuilderBase::mergeFromDirectory(IPartWriteStream& ws,
|
bool DiscBuilderBase::PartitionBuilderBase::mergeFromDirectory(IPartWriteStream& ws,
|
||||||
const nod::Partition* partIn,
|
const IPartition* partIn,
|
||||||
SystemStringView dirIn)
|
SystemStringView dirIn)
|
||||||
{
|
{
|
||||||
if (dirIn.empty())
|
if (dirIn.empty())
|
||||||
@ -924,7 +949,7 @@ bool DiscBuilderBase::PartitionBuilderBase::mergeFromDirectory(IPartWriteStream&
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeMerge(const DiscBase::IPartition* partIn,
|
uint64_t DiscBuilderBase::PartitionBuilderBase::CalculateTotalSizeMerge(const IPartition* partIn,
|
||||||
SystemStringView dirIn)
|
SystemStringView dirIn)
|
||||||
{
|
{
|
||||||
SystemString dirStr(dirIn);
|
SystemString dirStr(dirIn);
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#include "nod/DiscGCN.hpp"
|
#include "nod/DiscGCN.hpp"
|
||||||
#include "nod/nod.hpp"
|
#include "nod/nod.hpp"
|
||||||
#include <inttypes.h>
|
#include <cinttypes>
|
||||||
#define BUFFER_SZ 0x8000
|
#define BUFFER_SZ 0x8000
|
||||||
|
|
||||||
namespace nod
|
namespace nod
|
||||||
{
|
{
|
||||||
|
|
||||||
class PartitionGCN : public DiscBase::IPartition
|
class PartitionGCN : public IPartition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PartitionGCN(const DiscGCN& parent, uint64_t offset, bool& err)
|
PartitionGCN(const DiscGCN& parent, uint64_t offset, bool& err)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include "nod/Util.hpp"
|
#include "nod/Util.hpp"
|
||||||
#include "nod/IDiscIO.hpp"
|
#include "nod/IDiscIO.hpp"
|
||||||
#include "nod/IFileIO.hpp"
|
#include "nod/IFileIO.hpp"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <inttypes.h>
|
#include <cinttypes>
|
||||||
#include "nod/Util.hpp"
|
#include "nod/Util.hpp"
|
||||||
#include "nod/IDiscIO.hpp"
|
#include "nod/IDiscIO.hpp"
|
||||||
#include "nod/IFileIO.hpp"
|
#include "nod/IFileIO.hpp"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <inttypes.h>
|
#include <cinttypes>
|
||||||
#include "nod/DiscWii.hpp"
|
#include "nod/DiscWii.hpp"
|
||||||
#include "nod/aes.hpp"
|
#include "nod/aes.hpp"
|
||||||
#include "nod/sha1.h"
|
#include "nod/sha1.h"
|
||||||
@ -24,7 +24,7 @@ static const uint8_t COMMON_KEYS[2][16] =
|
|||||||
0xba, 0x4c, 0x9b, 0x7e}
|
0xba, 0x4c, 0x9b, 0x7e}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PartitionWii : public DiscBase::IPartition
|
class PartitionWii : public IPartition
|
||||||
{
|
{
|
||||||
enum class SigType : uint32_t
|
enum class SigType : uint32_t
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <inttypes.h>
|
#include <cinttypes>
|
||||||
#include "nod/Util.hpp"
|
#include "nod/Util.hpp"
|
||||||
#include "nod/IFileIO.hpp"
|
#include "nod/IFileIO.hpp"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <cstdlib>
|
||||||
#include <inttypes.h>
|
#include <cinttypes>
|
||||||
#include "nod/Util.hpp"
|
#include "nod/Util.hpp"
|
||||||
#include "nod/IFileIO.hpp"
|
#include "nod/IFileIO.hpp"
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "nod/aes.hpp"
|
#include "nod/aes.hpp"
|
||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
#if _WIN32
|
#if _WIN32
|
||||||
#include <intrin.h>
|
#include <intrin.h>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <stdio.h>
|
#include <cstdio>
|
||||||
#include "nod/nod.hpp"
|
#include "nod/nod.hpp"
|
||||||
#include "nod/DiscBase.hpp"
|
#include "nod/DiscBase.hpp"
|
||||||
|
|
||||||
|
2
logvisor
2
logvisor
@ -1 +1 @@
|
|||||||
Subproject commit 408ae926d76128fa23a12607d0a1e0a970ab3554
|
Subproject commit beee8b397056efcdc33020a26cf69d1039f0f802
|
Loading…
x
Reference in New Issue
Block a user