Added `writeSysFiles` for convience of integration

This commit is contained in:
Phillip Stephens 2017-07-09 01:25:43 -07:00
parent a7c19799e1
commit 72169e8e77
2 changed files with 25 additions and 15 deletions

View File

@ -381,6 +381,7 @@ public:
inline const Header& getHeader() const { return m_header; }
inline const BI2Header& getBI2() const { return m_bi2Header; }
virtual bool extractCryptoFiles(const SystemString& path, const ExtractionContext& ctx) const { return true; }
bool extractSysFiles(const SystemString& path, const ExtractionContext& ctx) const;
};
protected:

View File

@ -169,12 +169,6 @@ bool DiscBase::IPartition::extractToDirectory(const SystemString& path,
}
}
if (Mkdir((basePath + _S("/sys")).c_str(), 0755) && errno != EEXIST)
{
LogModule.report(logvisor::Error, _S("unable to mkdir '%s/sys'"), basePath.c_str());
return false;
}
/* Extract Disc Files */
if (!m_parent.extractDiscHeaderFiles(basePath, ctx))
return false;
@ -183,6 +177,29 @@ bool DiscBase::IPartition::extractToDirectory(const SystemString& path,
if (!extractCryptoFiles(basePath, ctx))
return false;
if (!extractSysFiles(basePath, ctx))
return false;
/* Extract Filesystem */
SystemString fsPath = basePath + _S("/files");
if (Mkdir(fsPath.c_str(), 0755) && errno != EEXIST)
{
LogModule.report(logvisor::Error, _S("unable to mkdir '%s'"), fsPath.c_str());
return false;
}
return m_nodes[0].extractToDirectory(fsPath, ctx);
}
bool DiscBase::IPartition::extractSysFiles(const SystemString& basePath, const ExtractionContext& ctx) const
{
if (Mkdir((basePath + _S("/sys")).c_str(), 0755) && errno != EEXIST)
{
LogModule.report(logvisor::Error, _S("unable to mkdir '%s/sys'"), basePath.c_str());
return false;
}
Sstat theStat;
/* Extract Apploader */
SystemString apploaderPath = basePath + _S("/sys/apploader.img");
if (ctx.force || Stat(apploaderPath.c_str(), &theStat))
@ -234,15 +251,7 @@ bool DiscBase::IPartition::extractToDirectory(const SystemString& path,
m_bi2Header.write(*ws);
}
/* Extract Filesystem */
SystemString fsPath = basePath + _S("/files");
if (Mkdir(fsPath.c_str(), 0755) && errno != EEXIST)
{
LogModule.report(logvisor::Error, _S("unable to mkdir '%s'"), fsPath.c_str());
return false;
}
return m_nodes[0].extractToDirectory(fsPath, ctx);
return true;
}
static uint64_t GetInode(const SystemChar* path)