mirror of
https://github.com/jakcron/nstool
synced 2024-11-22 21:49:30 +00:00
Move IniProcess and KipProcess
This commit is contained in:
parent
672828839a
commit
054776b586
5 changed files with 32 additions and 16 deletions
|
@ -185,7 +185,9 @@
|
||||||
<ClCompile Include="..\..\..\src\EsTikProcess.cpp" />
|
<ClCompile Include="..\..\..\src\EsTikProcess.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\FsProcess.cpp" />
|
<ClCompile Include="..\..\..\src\FsProcess.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\GameCardProcess.cpp" />
|
<ClCompile Include="..\..\..\src\GameCardProcess.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\src\IniProcess.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\KeyBag.cpp" />
|
<ClCompile Include="..\..\..\src\KeyBag.cpp" />
|
||||||
|
<ClCompile Include="..\..\..\src\KipProcess.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\main.cpp" />
|
<ClCompile Include="..\..\..\src\main.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\MetaProcess.cpp" />
|
<ClCompile Include="..\..\..\src\MetaProcess.cpp" />
|
||||||
<ClCompile Include="..\..\..\src\NacpProcess.cpp" />
|
<ClCompile Include="..\..\..\src\NacpProcess.cpp" />
|
||||||
|
|
|
@ -152,5 +152,11 @@
|
||||||
<ClCompile Include="..\..\..\src\MetaProcess.cpp">
|
<ClCompile Include="..\..\..\src\MetaProcess.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\src\IniProcess.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\src\KipProcess.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
|
|
||||||
nstool::IniProcess::IniProcess() :
|
nstool::IniProcess::IniProcess() :
|
||||||
|
mModuleName("nstool::IniProcess"),
|
||||||
mFile(),
|
mFile(),
|
||||||
mCliOutputMode(true, false, false, false),
|
mCliOutputMode(true, false, false, false),
|
||||||
mVerify(false),
|
mVerify(false),
|
||||||
|
@ -27,7 +28,7 @@ void nstool::IniProcess::process()
|
||||||
displayHeader();
|
displayHeader();
|
||||||
displayKipList();
|
displayKipList();
|
||||||
}
|
}
|
||||||
if (mDoExtractKip)
|
if (mKipExtractPath.isSet())
|
||||||
{
|
{
|
||||||
extractKipList();
|
extractKipList();
|
||||||
}
|
}
|
||||||
|
@ -48,29 +49,35 @@ void nstool::IniProcess::setVerifyMode(bool verify)
|
||||||
mVerify = verify;
|
mVerify = verify;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nstool::IniProcess::setKipExtractPath(const std::string& path)
|
void nstool::IniProcess::setKipExtractPath(const tc::io::Path& path)
|
||||||
{
|
{
|
||||||
mDoExtractKip = true;
|
|
||||||
mKipExtractPath = path;
|
mKipExtractPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nstool::IniProcess::importHeader()
|
void nstool::IniProcess::importHeader()
|
||||||
{
|
{
|
||||||
tc::ByteData scratch;
|
if (mFile == nullptr)
|
||||||
|
|
||||||
if (*mFile == nullptr)
|
|
||||||
{
|
{
|
||||||
throw tc::Exception(kModuleName, "No file reader set.");
|
throw tc::Exception(mModuleName, "No file reader set.");
|
||||||
|
}
|
||||||
|
if (mFile->canRead() == false || mFile->canSeek() == false)
|
||||||
|
{
|
||||||
|
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*mFile)->size() < sizeof(nn::hac::sIniHeader))
|
// check if file_size is smaller than INI header size
|
||||||
|
size_t file_size = tc::io::IOUtil::castInt64ToSize(mFile->length());
|
||||||
|
if (file_size < sizeof(nn::hac::sIniHeader))
|
||||||
{
|
{
|
||||||
throw tc::Exception(kModuleName, "Corrupt INI: file too small");
|
throw tc::Exception(mModuleName, "Corrupt NSO: file too small.");
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch.alloc(sizeof(nn::hac::sIniHeader));
|
// read ini
|
||||||
(*mFile)->read(scratch.data(), 0, scratch.size());
|
tc::ByteData scratch = tc::ByteData(sizeof(nn::hac::sIniHeader));
|
||||||
|
mFile->seek(0, tc::io::SeekOrigin::Begin);
|
||||||
|
mFile->read(scratch.data(), scratch.size());
|
||||||
|
|
||||||
|
// parse ini header
|
||||||
mHdr.fromBytes(scratch.data(), scratch.size());
|
mHdr.fromBytes(scratch.data(), scratch.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,9 +104,9 @@ void nstool::IniProcess::importKipList()
|
||||||
|
|
||||||
void nstool::IniProcess::displayHeader()
|
void nstool::IniProcess::displayHeader()
|
||||||
{
|
{
|
||||||
std::cout << "[INI Header]" << std::endl;
|
fmt::print("[INI Header]\n");
|
||||||
std::cout << " Size: 0x" << std::hex << mHdr.getSize() << std::endl;
|
fmt::print(" Size: 0x{:x}\n", mHdr.getSize());
|
||||||
std::cout << " KIP Num: " << std::dec << (uint32_t)mHdr.getKipNum() << std::endl;
|
fmt::print(" KIP Num: {:d}\n", mHdr.getKipNum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void nstool::IniProcess::displayKipList()
|
void nstool::IniProcess::displayKipList()
|
||||||
|
@ -123,7 +130,7 @@ void nstool::IniProcess::extractKipList()
|
||||||
|
|
||||||
|
|
||||||
// allocate cache memory
|
// allocate cache memory
|
||||||
cache.alloc(kCacheSize);
|
cache = tc::ByteData(kCacheSize);
|
||||||
|
|
||||||
// make extract dir
|
// make extract dir
|
||||||
fnd::io::makeDirectory(mKipExtractPath);
|
fnd::io::makeDirectory(mKipExtractPath);
|
|
@ -19,10 +19,11 @@ public:
|
||||||
|
|
||||||
void setKipExtractPath(const tc::io::Path& path);
|
void setKipExtractPath(const tc::io::Path& path);
|
||||||
private:
|
private:
|
||||||
const std::string kModuleName = "IniProcess";
|
|
||||||
const std::string kKipExtention = ".kip";
|
const std::string kKipExtention = ".kip";
|
||||||
const size_t kCacheSize = 0x10000;
|
const size_t kCacheSize = 0x10000;
|
||||||
|
|
||||||
|
std::string mModuleName;
|
||||||
|
|
||||||
std::shared_ptr<tc::io::IStream> mFile;
|
std::shared_ptr<tc::io::IStream> mFile;
|
||||||
CliOutputMode mCliOutputMode;
|
CliOutputMode mCliOutputMode;
|
||||||
bool mVerify;
|
bool mVerify;
|
||||||
|
|
Loading…
Reference in a new issue