From 78262bc68006d813acda68c56b2a33a18a732cb2 Mon Sep 17 00:00:00 2001 From: jakcron Date: Wed, 13 Oct 2021 15:41:02 +0800 Subject: [PATCH] Misc --- src/AssetProcess.cpp | 18 ++++++------- src/AssetProcess.h | 5 ++-- src/CnmtProcess.h | 1 - src/EsTikProcess.h | 1 - src/FsProcess.cpp | 56 +++++++++++++++++++------------------- src/FsProcess.h | 4 +-- src/GameCardProcess.h | 5 ++-- src/PfsProcess.cpp | 62 +++++++++++++++++++++---------------------- src/PfsProcess.h | 4 +-- src/RomfsProcess.cpp | 62 +++++++++++++++++++++---------------------- src/RomfsProcess.h | 4 +-- 11 files changed, 109 insertions(+), 113 deletions(-) diff --git a/src/AssetProcess.cpp b/src/AssetProcess.cpp index 7111f5c..b384db7 100644 --- a/src/AssetProcess.cpp +++ b/src/AssetProcess.cpp @@ -8,7 +8,15 @@ nstool::AssetProcess::AssetProcess() : mCliOutputMode(true, false, false, false), mVerify(false) { -} +} + +void nstool::AssetProcess::process() +{ + importHeader(); + if (mCliOutputMode.show_basic_info) + displayHeader(); + processSections(); +} void nstool::AssetProcess::setInputFile(const std::shared_ptr& file) { @@ -45,14 +53,6 @@ void nstool::AssetProcess::setRomfsExtractJobs(const std::vector& file); void setCliOutputMode(CliOutputMode type); void setVerifyMode(bool verify); @@ -21,9 +23,6 @@ public: void setRomfsShowFsTree(bool show_fs_tree); void setRomfsExtractJobs(const std::vector& extract_jobs); - - void process(); - private: std::string mModuleName; diff --git a/src/CnmtProcess.h b/src/CnmtProcess.h index bcb407d..ed38187 100644 --- a/src/CnmtProcess.h +++ b/src/CnmtProcess.h @@ -17,7 +17,6 @@ public: void setVerifyMode(bool verify); const nn::hac::ContentMeta& getContentMeta() const; - private: std::string mModuleName; diff --git a/src/EsTikProcess.h b/src/EsTikProcess.h index d146b65..1af1c30 100644 --- a/src/EsTikProcess.h +++ b/src/EsTikProcess.h @@ -20,7 +20,6 @@ public: void setCertificateChain(const std::vector>& certs); void setCliOutputMode(CliOutputMode mode); void setVerifyMode(bool verify); - private: std::string mModuleName; diff --git a/src/FsProcess.cpp b/src/FsProcess.cpp index d148336..f192589 100644 --- a/src/FsProcess.cpp +++ b/src/FsProcess.cpp @@ -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& input_fs) { mInputFs = input_fs; @@ -54,34 +82,6 @@ void nstool::FsProcess::setExtractJobs(const std::vector& ex 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() { fmt::print("[{:s}/Tree]\n", (mFsFormatName.isSet() ? mFsFormatName.get() : "FileSystem")); diff --git a/src/FsProcess.h b/src/FsProcess.h index d9b5e3b..70fc909 100644 --- a/src/FsProcess.h +++ b/src/FsProcess.h @@ -12,6 +12,8 @@ class FsProcess public: FsProcess(); + void process(); + void setInputFileSystem(const std::shared_ptr& input_fs); void setFsFormatName(const std::string& fs_format_name); void setFsProperties(const std::vector& properties); @@ -19,8 +21,6 @@ public: void setShowFsTree(bool show_fs_tree); void setFsRootLabel(const std::string& root_label); void setExtractJobs(const std::vector& extract_jobs); - - void process(); private: std::string mModuleLabel; diff --git a/src/GameCardProcess.h b/src/GameCardProcess.h index 0be04a8..7e984f5 100644 --- a/src/GameCardProcess.h +++ b/src/GameCardProcess.h @@ -12,6 +12,8 @@ class GameCardProcess public: GameCardProcess(); + void process(); + // generic void setInputFile(const std::shared_ptr& file); void setKeyCfg(const KeyBag& keycfg); @@ -21,9 +23,6 @@ public: // fs specific void setShowFsTree(bool show_fs_tree); void setExtractJobs(const std::vector extract_jobs); - - void process(); - private: const std::string kXciMountPointName = "gamecard"; diff --git a/src/PfsProcess.cpp b/src/PfsProcess.cpp index b32606a..6099951 100644 --- a/src/PfsProcess.cpp +++ b/src/PfsProcess.cpp @@ -20,37 +20,6 @@ nstool::PfsProcess::PfsProcess() : mFsProcess.setFsFormatName("PartitionFS"); } -void nstool::PfsProcess::setInputFile(const std::shared_ptr& 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& extract_jobs) -{ - mFsProcess.setExtractJobs(extract_jobs); -} - void nstool::PfsProcess::process() { if (mFile == nullptr) @@ -105,6 +74,37 @@ void nstool::PfsProcess::process() mFsProcess.process(); } +void nstool::PfsProcess::setInputFile(const std::shared_ptr& 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& extract_jobs) +{ + mFsProcess.setExtractJobs(extract_jobs); +} + const nn::hac::PartitionFsHeader& nstool::PfsProcess::getPfsHeader() const { return mPfs; diff --git a/src/PfsProcess.h b/src/PfsProcess.h index 00b205c..e3ff3c5 100644 --- a/src/PfsProcess.h +++ b/src/PfsProcess.h @@ -11,6 +11,8 @@ class PfsProcess public: PfsProcess(); + void process(); + // generic void setInputFile(const std::shared_ptr& file); void setCliOutputMode(CliOutputMode type); @@ -21,8 +23,6 @@ public: void setFsRootLabel(const std::string& root_label); void setExtractJobs(const std::vector& extract_jobs); - void process(); - // post process() get PFS/FS out const nn::hac::PartitionFsHeader& getPfsHeader() const; const std::shared_ptr& getFileSystem() const; diff --git a/src/RomfsProcess.cpp b/src/RomfsProcess.cpp index 23e737f..1c5bfe1 100644 --- a/src/RomfsProcess.cpp +++ b/src/RomfsProcess.cpp @@ -18,37 +18,6 @@ nstool::RomfsProcess::RomfsProcess() : mFsProcess.setFsFormatName("RomFS"); } -void nstool::RomfsProcess::setInputFile(const std::shared_ptr& 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& extract_jobs) -{ - mFsProcess.setExtractJobs(extract_jobs); -} - -void nstool::RomfsProcess::setShowFsTree(bool list_fs) -{ - mFsProcess.setShowFsTree(list_fs); -} - void nstool::RomfsProcess::process() { if (mFile == nullptr) @@ -125,4 +94,35 @@ void nstool::RomfsProcess::process() // process filesystem mFsProcess.process(); +} + +void nstool::RomfsProcess::setInputFile(const std::shared_ptr& 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& extract_jobs) +{ + mFsProcess.setExtractJobs(extract_jobs); +} + +void nstool::RomfsProcess::setShowFsTree(bool list_fs) +{ + mFsProcess.setShowFsTree(list_fs); } \ No newline at end of file diff --git a/src/RomfsProcess.h b/src/RomfsProcess.h index 6f2304c..9d99609 100644 --- a/src/RomfsProcess.h +++ b/src/RomfsProcess.h @@ -11,6 +11,8 @@ class RomfsProcess public: RomfsProcess(); + void process(); + // generic void setInputFile(const std::shared_ptr& file); void setCliOutputMode(CliOutputMode type); @@ -20,8 +22,6 @@ public: void setFsRootLabel(const std::string& root_label); void setExtractJobs(const std::vector& extract_jobs); void setShowFsTree(bool show_fs_tree); - - void process(); private: static const size_t kCacheSize = 0x10000;