Extraction progress logs are now only shown in verbose mode.

This commit is contained in:
Jakcron
2022-04-15 00:21:35 +08:00
parent c0ce043b30
commit 247045ba8f
6 changed files with 60 additions and 21 deletions
+5 -2
View File
@@ -209,7 +209,7 @@ void ctrtool::CciProcess::importHeader()
// Since CCM mode decrypts AND verifies, we should process the result here if required
if (mVerify)
{
mValidInitialDataMac = dec_result == 0 ? ValidState::Good : ValidState::Fail;
mValidInitialDataMac = dec_result == 0 ? ValidState::Good : ValidState::Fail;
if (mValidInitialDataMac != ValidState::Good)
{
@@ -361,7 +361,10 @@ void ctrtool::CciProcess::extractFs()
// build out path
out_path = mExtractPath.get() + *itr;
fmt::print(stderr, "[{} LOG] Saving {}...\n", mModuleLabel, out_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving {}...\n", mModuleLabel, out_path.to_string());
}
// begin export
mFsReader->openFile(*itr, tc::io::FileMode::Open, tc::io::FileAccess::Read, in_stream);
+22 -5
View File
@@ -702,7 +702,11 @@ void ctrtool::CiaProcess::extractCia()
in_stream = std::shared_ptr<tc::io::SubStream>(new tc::io::SubStream(mInputStream, mCertSizeInfo.offset, mCertSizeInfo.size));
out_stream = std::shared_ptr<tc::io::FileStream>(new tc::io::FileStream(out_path, tc::io::FileMode::OpenOrCreate, tc::io::FileAccess::Write));
fmt::print(stderr, "[{} LOG] Saving certs to {}...\n", mModuleLabel, out_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving certs to {}...\n", mModuleLabel, out_path.to_string());
}
copyStream(in_stream, out_stream);
}
@@ -713,7 +717,10 @@ void ctrtool::CiaProcess::extractCia()
in_stream = std::shared_ptr<tc::io::SubStream>(new tc::io::SubStream(mInputStream, mTikSizeInfo.offset, mTikSizeInfo.size));
out_stream = std::shared_ptr<tc::io::FileStream>(new tc::io::FileStream(out_path, tc::io::FileMode::OpenOrCreate, tc::io::FileAccess::Write));
fmt::print(stderr, "[{} LOG] Saving tik to {}...\n", mModuleLabel, out_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving tik to {}...\n", mModuleLabel, out_path.to_string());
}
copyStream(in_stream, out_stream);
}
@@ -724,7 +731,10 @@ void ctrtool::CiaProcess::extractCia()
in_stream = std::shared_ptr<tc::io::SubStream>(new tc::io::SubStream(mInputStream, mTmdSizeInfo.offset, mTmdSizeInfo.size));
out_stream = std::shared_ptr<tc::io::FileStream>(new tc::io::FileStream(out_path, tc::io::FileMode::OpenOrCreate, tc::io::FileAccess::Write));
fmt::print(stderr, "[{} LOG] Saving tmd to {}...\n", mModuleLabel, out_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving tmd to {}...\n", mModuleLabel, out_path.to_string());
}
copyStream(in_stream, out_stream);
}
@@ -735,7 +745,10 @@ void ctrtool::CiaProcess::extractCia()
in_stream = std::shared_ptr<tc::io::SubStream>(new tc::io::SubStream(mInputStream, mFooterSizeInfo.offset, mFooterSizeInfo.size));
out_stream = std::shared_ptr<tc::io::FileStream>(new tc::io::FileStream(out_path, tc::io::FileMode::OpenOrCreate, tc::io::FileAccess::Write));
fmt::print(stderr, "[{} LOG] Saving meta to {}...\n", mModuleLabel, out_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving meta to {}...\n", mModuleLabel, out_path.to_string());
}
copyStream(in_stream, out_stream);
}
@@ -758,7 +771,11 @@ void ctrtool::CiaProcess::extractCia()
out_stream = std::shared_ptr<tc::io::FileStream>(new tc::io::FileStream(out_path, tc::io::FileMode::OpenOrCreate, tc::io::FileAccess::Write));
fmt::print(stderr, "[{} LOG] Saving content {:04x} to {}...\n", mModuleLabel, itr->second.cindex, out_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving content {:04x} to {}...\n", mModuleLabel, itr->second.cindex, out_path.to_string());
}
copyStream(in_stream, out_stream);
}
}
+14 -5
View File
@@ -223,8 +223,11 @@ void ctrtool::ExeFsProcess::extractFs()
}
if (test_hash != nullptr && memcmp(test_hash, hash.data(), hash.size()) == 0)
{
fmt::print(stderr, "[{} LOG] Decompressing file /{} to {}...\n", mModuleLabel, *itr, f_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Decompressing {} to {}...\n", mModuleLabel, *itr, f_path.to_string());
}
tc::ByteData decompdata = tc::ByteData(lzss_get_decompressed_size(compdata.data(), compdata.size()));
lzss_decompress(compdata.data(), compdata.size(), decompdata.data(), decompdata.size());
@@ -233,7 +236,10 @@ void ctrtool::ExeFsProcess::extractFs()
}
else
{
fmt::print(stderr, "[{} LOG] Saving file /{} to {}...\n", mModuleLabel, *itr, f_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving {} to {}...\n", mModuleLabel, *itr, f_path.to_string());
}
out_stream->seek(0, tc::io::SeekOrigin::Begin);
out_stream->write(compdata.data(), compdata.size());
@@ -241,8 +247,11 @@ void ctrtool::ExeFsProcess::extractFs()
}
else
{
fmt::print(stderr, "[{} LOG] Saving file /{} to {}...\n", mModuleLabel, *itr, f_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving {} to {}...\n", mModuleLabel, *itr, f_path.to_string());
}
tc::ByteData filedata = tc::ByteData(in_stream->length());
in_stream->seek(0, tc::io::SeekOrigin::Begin);
in_stream->read(filedata.data(), filedata.size());
+4 -1
View File
@@ -311,7 +311,10 @@ void ctrtool::FirmProcess::extractSections()
local_fs.createDirectory(mExtractPath.get());
local_fs.openFile(f_path, tc::io::FileMode::OpenOrCreate, tc::io::FileAccess::Write, out_stream);
fmt::print("Saving section {} to {}...\n", i, f_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving section {} to {}...\n", mModuleLabel, i, f_path.to_string());
}
tc::ByteData filedata = tc::ByteData(in_stream->length());
in_stream->seek(0, tc::io::SeekOrigin::Begin);
+11 -7
View File
@@ -768,15 +768,19 @@ void ctrtool::NcchProcess::extractRegionBinaries()
{
if (mRegionOpt[i].bin_extract_path.isSet() && mRegionInfo[i].ready_stream != nullptr)
{
switch(i)
if (mVerbose)
{
case NcchRegion_Header: fmt::print("Saving Header...\n"); break;
case NcchRegion_ExHeader: fmt::print("Saving Extended Header...\n"); break;
case NcchRegion_PlainRegion: fmt::print("Saving Plain Region...\n"); break;
case NcchRegion_Logo: fmt::print("Saving Logo...\n"); break;
case NcchRegion_ExeFs: fmt::print("Saving ExeFS...\n"); break;
case NcchRegion_RomFs: fmt::print("Saving RomFS...\n"); break;
switch(i)
{
case NcchRegion_Header: fmt::print(stderr, "[{} LOG] Saving Header...\n", mModuleLabel); break;
case NcchRegion_ExHeader: fmt::print(stderr, "[{} LOG] Saving Extended Header...\n", mModuleLabel); break;
case NcchRegion_PlainRegion: fmt::print(stderr, "[{} LOG] Saving Plain Region...\n", mModuleLabel); break;
case NcchRegion_Logo: fmt::print(stderr, "[{} LOG] Saving Logo...\n", mModuleLabel); break;
case NcchRegion_ExeFs: fmt::print(stderr, "[{} LOG] Saving ExeFS...\n", mModuleLabel); break;
case NcchRegion_RomFs: fmt::print(stderr, "[{} LOG] Saving RomFS...\n", mModuleLabel); break;
}
}
in_stream = mRegionInfo[i].ready_stream;
local_fs.openFile(mRegionOpt[i].bin_extract_path.get(), tc::io::FileMode::OpenOrCreate, tc::io::FileAccess::Write, out_stream);
+4 -1
View File
@@ -200,7 +200,10 @@ void ctrtool::RomFsProcess::visitDir(const tc::io::Path& v_path, const tc::io::P
// build out path
out_path = l_path + *itr;
fmt::print(stderr, "[{} LOG] Saving {}...\n", mModuleLabel, out_path.to_string());
if (mVerbose)
{
fmt::print(stderr, "[{} LOG] Saving {}...\n", mModuleLabel, out_path.to_string());
}
// begin export
mFsReader->openFile(v_path + *itr, tc::io::FileMode::Open, tc::io::FileAccess::Read, in_stream);