This commit is contained in:
jakcron 2021-10-13 15:41:02 +08:00
parent defccc6ddf
commit 78262bc680
11 changed files with 109 additions and 113 deletions

View file

@ -10,6 +10,14 @@ nstool::AssetProcess::AssetProcess() :
{ {
} }
void nstool::AssetProcess::process()
{
importHeader();
if (mCliOutputMode.show_basic_info)
displayHeader();
processSections();
}
void nstool::AssetProcess::setInputFile(const std::shared_ptr<tc::io::IStream>& file) void nstool::AssetProcess::setInputFile(const std::shared_ptr<tc::io::IStream>& file)
{ {
mFile = file; mFile = file;
@ -45,14 +53,6 @@ void nstool::AssetProcess::setRomfsExtractJobs(const std::vector<nstool::Extract
mRomfs.setExtractJobs(extract_jobs); mRomfs.setExtractJobs(extract_jobs);
} }
void nstool::AssetProcess::process()
{
importHeader();
if (mCliOutputMode.show_basic_info)
displayHeader();
processSections();
}
void nstool::AssetProcess::importHeader() void nstool::AssetProcess::importHeader()
{ {
if (mFile == nullptr) if (mFile == nullptr)

View file

@ -12,6 +12,8 @@ class AssetProcess
public: public:
AssetProcess(); AssetProcess();
void process();
void setInputFile(const std::shared_ptr<tc::io::IStream>& file); void setInputFile(const std::shared_ptr<tc::io::IStream>& file);
void setCliOutputMode(CliOutputMode type); void setCliOutputMode(CliOutputMode type);
void setVerifyMode(bool verify); void setVerifyMode(bool verify);
@ -21,9 +23,6 @@ public:
void setRomfsShowFsTree(bool show_fs_tree); void setRomfsShowFsTree(bool show_fs_tree);
void setRomfsExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs); void setRomfsExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs);
void process();
private: private:
std::string mModuleName; std::string mModuleName;

View file

@ -17,7 +17,6 @@ public:
void setVerifyMode(bool verify); void setVerifyMode(bool verify);
const nn::hac::ContentMeta& getContentMeta() const; const nn::hac::ContentMeta& getContentMeta() const;
private: private:
std::string mModuleName; std::string mModuleName;

View file

@ -20,7 +20,6 @@ public:
void setCertificateChain(const std::vector<nn::pki::SignedData<nn::pki::CertificateBody>>& certs); void setCertificateChain(const std::vector<nn::pki::SignedData<nn::pki::CertificateBody>>& certs);
void setCliOutputMode(CliOutputMode mode); void setCliOutputMode(CliOutputMode mode);
void setVerifyMode(bool verify); void setVerifyMode(bool verify);
private: private:
std::string mModuleName; std::string mModuleName;

View file

@ -19,6 +19,34 @@ nstool::FsProcess::FsProcess() :
} }
void nstool::FsProcess::process()
{
if (mInputFs == nullptr)
{
throw tc::InvalidOperationException(mModuleLabel, "No input filesystem");
}
if (mShowFsInfo)
{
fmt::print("[{:s}]\n", mFsFormatName.isSet() ? mFsFormatName.get() : "FileSystem/Info");
for (auto itr = mProperties.begin(); itr != mProperties.end(); itr++)
{
fmt::print(" {:s}\n", *itr);
}
}
if (mShowFsTree)
{
printFs();
}
if (mExtractJobs.empty() == false)
{
extractFs();
}
}
void nstool::FsProcess::setInputFileSystem(const std::shared_ptr<tc::io::IStorage>& input_fs) void nstool::FsProcess::setInputFileSystem(const std::shared_ptr<tc::io::IStorage>& input_fs)
{ {
mInputFs = input_fs; mInputFs = input_fs;
@ -54,34 +82,6 @@ void nstool::FsProcess::setExtractJobs(const std::vector<nstool::ExtractJob>& ex
mExtractJobs = extract_jobs; mExtractJobs = extract_jobs;
} }
void nstool::FsProcess::process()
{
if (mInputFs == nullptr)
{
throw tc::InvalidOperationException(mModuleLabel, "No input filesystem");
}
if (mShowFsInfo)
{
fmt::print("[{:s}]\n", mFsFormatName.isSet() ? mFsFormatName.get() : "FileSystem/Info");
for (auto itr = mProperties.begin(); itr != mProperties.end(); itr++)
{
fmt::print(" {:s}\n", *itr);
}
}
if (mShowFsTree)
{
printFs();
}
if (mExtractJobs.empty() == false)
{
extractFs();
}
}
void nstool::FsProcess::printFs() void nstool::FsProcess::printFs()
{ {
fmt::print("[{:s}/Tree]\n", (mFsFormatName.isSet() ? mFsFormatName.get() : "FileSystem")); fmt::print("[{:s}/Tree]\n", (mFsFormatName.isSet() ? mFsFormatName.get() : "FileSystem"));

View file

@ -12,6 +12,8 @@ class FsProcess
public: public:
FsProcess(); FsProcess();
void process();
void setInputFileSystem(const std::shared_ptr<tc::io::IStorage>& input_fs); void setInputFileSystem(const std::shared_ptr<tc::io::IStorage>& input_fs);
void setFsFormatName(const std::string& fs_format_name); void setFsFormatName(const std::string& fs_format_name);
void setFsProperties(const std::vector<std::string>& properties); void setFsProperties(const std::vector<std::string>& properties);
@ -19,8 +21,6 @@ public:
void setShowFsTree(bool show_fs_tree); void setShowFsTree(bool show_fs_tree);
void setFsRootLabel(const std::string& root_label); void setFsRootLabel(const std::string& root_label);
void setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs); void setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs);
void process();
private: private:
std::string mModuleLabel; std::string mModuleLabel;

View file

@ -12,6 +12,8 @@ class GameCardProcess
public: public:
GameCardProcess(); GameCardProcess();
void process();
// generic // generic
void setInputFile(const std::shared_ptr<tc::io::IStream>& file); void setInputFile(const std::shared_ptr<tc::io::IStream>& file);
void setKeyCfg(const KeyBag& keycfg); void setKeyCfg(const KeyBag& keycfg);
@ -21,9 +23,6 @@ public:
// fs specific // fs specific
void setShowFsTree(bool show_fs_tree); void setShowFsTree(bool show_fs_tree);
void setExtractJobs(const std::vector<nstool::ExtractJob> extract_jobs); void setExtractJobs(const std::vector<nstool::ExtractJob> extract_jobs);
void process();
private: private:
const std::string kXciMountPointName = "gamecard"; const std::string kXciMountPointName = "gamecard";

View file

@ -20,37 +20,6 @@ nstool::PfsProcess::PfsProcess() :
mFsProcess.setFsFormatName("PartitionFS"); mFsProcess.setFsFormatName("PartitionFS");
} }
void nstool::PfsProcess::setInputFile(const std::shared_ptr<tc::io::IStream>& file)
{
mFile = file;
}
void nstool::PfsProcess::setCliOutputMode(CliOutputMode type)
{
mCliOutputMode = type;
mFsProcess.setShowFsInfo(mCliOutputMode.show_basic_info);
}
void nstool::PfsProcess::setVerifyMode(bool verify)
{
mVerify = verify;
}
void nstool::PfsProcess::setShowFsTree(bool show_fs_tree)
{
mFsProcess.setShowFsTree(show_fs_tree);
}
void nstool::PfsProcess::setFsRootLabel(const std::string& root_label)
{
mFsProcess.setFsRootLabel(root_label);
}
void nstool::PfsProcess::setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs)
{
mFsProcess.setExtractJobs(extract_jobs);
}
void nstool::PfsProcess::process() void nstool::PfsProcess::process()
{ {
if (mFile == nullptr) if (mFile == nullptr)
@ -105,6 +74,37 @@ void nstool::PfsProcess::process()
mFsProcess.process(); mFsProcess.process();
} }
void nstool::PfsProcess::setInputFile(const std::shared_ptr<tc::io::IStream>& file)
{
mFile = file;
}
void nstool::PfsProcess::setCliOutputMode(CliOutputMode type)
{
mCliOutputMode = type;
mFsProcess.setShowFsInfo(mCliOutputMode.show_basic_info);
}
void nstool::PfsProcess::setVerifyMode(bool verify)
{
mVerify = verify;
}
void nstool::PfsProcess::setShowFsTree(bool show_fs_tree)
{
mFsProcess.setShowFsTree(show_fs_tree);
}
void nstool::PfsProcess::setFsRootLabel(const std::string& root_label)
{
mFsProcess.setFsRootLabel(root_label);
}
void nstool::PfsProcess::setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs)
{
mFsProcess.setExtractJobs(extract_jobs);
}
const nn::hac::PartitionFsHeader& nstool::PfsProcess::getPfsHeader() const const nn::hac::PartitionFsHeader& nstool::PfsProcess::getPfsHeader() const
{ {
return mPfs; return mPfs;

View file

@ -11,6 +11,8 @@ class PfsProcess
public: public:
PfsProcess(); PfsProcess();
void process();
// generic // generic
void setInputFile(const std::shared_ptr<tc::io::IStream>& file); void setInputFile(const std::shared_ptr<tc::io::IStream>& file);
void setCliOutputMode(CliOutputMode type); void setCliOutputMode(CliOutputMode type);
@ -21,8 +23,6 @@ public:
void setFsRootLabel(const std::string& root_label); void setFsRootLabel(const std::string& root_label);
void setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs); void setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs);
void process();
// post process() get PFS/FS out // post process() get PFS/FS out
const nn::hac::PartitionFsHeader& getPfsHeader() const; const nn::hac::PartitionFsHeader& getPfsHeader() const;
const std::shared_ptr<tc::io::IStorage>& getFileSystem() const; const std::shared_ptr<tc::io::IStorage>& getFileSystem() const;

View file

@ -18,37 +18,6 @@ nstool::RomfsProcess::RomfsProcess() :
mFsProcess.setFsFormatName("RomFS"); mFsProcess.setFsFormatName("RomFS");
} }
void nstool::RomfsProcess::setInputFile(const std::shared_ptr<tc::io::IStream>& file)
{
mFile = file;
}
void nstool::RomfsProcess::setCliOutputMode(CliOutputMode type)
{
mCliOutputMode = type;
mFsProcess.setShowFsInfo(mCliOutputMode.show_basic_info);
}
void nstool::RomfsProcess::setVerifyMode(bool verify)
{
mVerify = verify;
}
void nstool::RomfsProcess::setFsRootLabel(const std::string& root_label)
{
mFsProcess.setFsRootLabel(root_label);
}
void nstool::RomfsProcess::setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs)
{
mFsProcess.setExtractJobs(extract_jobs);
}
void nstool::RomfsProcess::setShowFsTree(bool list_fs)
{
mFsProcess.setShowFsTree(list_fs);
}
void nstool::RomfsProcess::process() void nstool::RomfsProcess::process()
{ {
if (mFile == nullptr) if (mFile == nullptr)
@ -126,3 +95,34 @@ void nstool::RomfsProcess::process()
// process filesystem // process filesystem
mFsProcess.process(); mFsProcess.process();
} }
void nstool::RomfsProcess::setInputFile(const std::shared_ptr<tc::io::IStream>& file)
{
mFile = file;
}
void nstool::RomfsProcess::setCliOutputMode(CliOutputMode type)
{
mCliOutputMode = type;
mFsProcess.setShowFsInfo(mCliOutputMode.show_basic_info);
}
void nstool::RomfsProcess::setVerifyMode(bool verify)
{
mVerify = verify;
}
void nstool::RomfsProcess::setFsRootLabel(const std::string& root_label)
{
mFsProcess.setFsRootLabel(root_label);
}
void nstool::RomfsProcess::setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs)
{
mFsProcess.setExtractJobs(extract_jobs);
}
void nstool::RomfsProcess::setShowFsTree(bool list_fs)
{
mFsProcess.setShowFsTree(list_fs);
}

View file

@ -11,6 +11,8 @@ class RomfsProcess
public: public:
RomfsProcess(); RomfsProcess();
void process();
// generic // generic
void setInputFile(const std::shared_ptr<tc::io::IStream>& file); void setInputFile(const std::shared_ptr<tc::io::IStream>& file);
void setCliOutputMode(CliOutputMode type); void setCliOutputMode(CliOutputMode type);
@ -20,8 +22,6 @@ public:
void setFsRootLabel(const std::string& root_label); void setFsRootLabel(const std::string& root_label);
void setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs); void setExtractJobs(const std::vector<nstool::ExtractJob>& extract_jobs);
void setShowFsTree(bool show_fs_tree); void setShowFsTree(bool show_fs_tree);
void process();
private: private:
static const size_t kCacheSize = 0x10000; static const size_t kCacheSize = 0x10000;