mirror of
https://github.com/jakcron/nstool.git
synced 2024-12-22 10:45:28 +00:00
Fix issue where RomFs with no files could not be processed.
This commit is contained in:
parent
390b544059
commit
b0a07c061a
2
deps/libpietendo
vendored
2
deps/libpietendo
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 89204ee499bfb3e4d1017c4a1fe2d29b2e70ff37
|
Subproject commit 994e70282691fb8cdb9276906500fd873ac51270
|
|
@ -20,6 +20,7 @@ nstool::RomfsProcess::RomfsProcess() :
|
||||||
|
|
||||||
void nstool::RomfsProcess::process()
|
void nstool::RomfsProcess::process()
|
||||||
{
|
{
|
||||||
|
// state checks
|
||||||
if (mFile == nullptr)
|
if (mFile == nullptr)
|
||||||
{
|
{
|
||||||
throw tc::Exception(mModuleName, "No file reader set.");
|
throw tc::Exception(mModuleName, "No file reader set.");
|
||||||
|
@ -29,8 +30,6 @@ void nstool::RomfsProcess::process()
|
||||||
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
throw tc::NotSupportedException(mModuleName, "Input stream requires read/seek permissions.");
|
||||||
}
|
}
|
||||||
|
|
||||||
tc::ByteData scratch;
|
|
||||||
|
|
||||||
// read base header to determine complete header size
|
// read base header to determine complete header size
|
||||||
if (mFile->length() < tc::io::IOUtil::castSizeToInt64(sizeof(pie::hac::sRomfsHeader)))
|
if (mFile->length() < tc::io::IOUtil::castSizeToInt64(sizeof(pie::hac::sRomfsHeader)))
|
||||||
{
|
{
|
||||||
|
@ -46,15 +45,41 @@ void nstool::RomfsProcess::process()
|
||||||
throw tc::ArgumentOutOfRangeException(mModuleName, "Corrupt RomFs: RomFsHeader is corrupted.");
|
throw tc::ArgumentOutOfRangeException(mModuleName, "Corrupt RomFs: RomFsHeader is corrupted.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
fmt::print("RomFsHeader:\n");
|
||||||
|
fmt::print(" > header_size = 0x{:04x}\n", mRomfsHeader.header_size.unwrap());
|
||||||
|
fmt::print(" > dir_hash_bucket\n");
|
||||||
|
fmt::print(" > offset = 0x{:04x}\n", mRomfsHeader.dir_hash_bucket.offset.unwrap());
|
||||||
|
fmt::print(" > size = 0x{:04x}\n", mRomfsHeader.dir_hash_bucket.size.unwrap());
|
||||||
|
fmt::print(" > dir_entry\n");
|
||||||
|
fmt::print(" > offset = 0x{:04x}\n", mRomfsHeader.dir_entry.offset.unwrap());
|
||||||
|
fmt::print(" > size = 0x{:04x}\n", mRomfsHeader.dir_entry.size.unwrap());
|
||||||
|
fmt::print(" > file_hash_bucket\n");
|
||||||
|
fmt::print(" > offset = 0x{:04x}\n", mRomfsHeader.file_hash_bucket.offset.unwrap())
|
||||||
|
fmt::print(" > size = 0x{:04x}\n", mRomfsHeader.file_hash_bucket.size.unwrap());
|
||||||
|
fmt::print(" > file_entry\n");
|
||||||
|
fmt::print(" > offset = 0x{:04x}\n", mRomfsHeader.file_entry.offset.unwrap());
|
||||||
|
fmt::print(" > size = 0x{:04x}\n", mRomfsHeader.file_entry.size.unwrap());
|
||||||
|
fmt::print(" > data_offset = 0x{:04x}\n", mRomfsHeader.data_offset.unwrap());
|
||||||
|
*/
|
||||||
|
|
||||||
// get dir entry ptr
|
// get dir entry ptr
|
||||||
tc::ByteData dir_entry_table = tc::ByteData(tc::io::IOUtil::castInt64ToSize(mRomfsHeader.dir_entry.size.unwrap()));
|
tc::ByteData dir_entry_table = tc::ByteData();
|
||||||
mFile->seek(mRomfsHeader.dir_entry.offset.unwrap(), tc::io::SeekOrigin::Begin);
|
if (mRomfsHeader.dir_entry.size.unwrap() > 0)
|
||||||
mFile->read(dir_entry_table.data(), dir_entry_table.size());
|
{
|
||||||
|
dir_entry_table = tc::ByteData(tc::io::IOUtil::castInt64ToSize(mRomfsHeader.dir_entry.size.unwrap()));
|
||||||
|
mFile->seek(mRomfsHeader.dir_entry.offset.unwrap(), tc::io::SeekOrigin::Begin);
|
||||||
|
mFile->read(dir_entry_table.data(), dir_entry_table.size());
|
||||||
|
}
|
||||||
|
|
||||||
// get file entry ptr
|
// get file entry ptr
|
||||||
tc::ByteData file_entry_table = tc::ByteData(tc::io::IOUtil::castInt64ToSize(mRomfsHeader.file_entry.size.unwrap()));
|
tc::ByteData file_entry_table = tc::ByteData();
|
||||||
mFile->seek(mRomfsHeader.file_entry.offset.unwrap(), tc::io::SeekOrigin::Begin);
|
if (mRomfsHeader.file_entry.size.unwrap() > 0)
|
||||||
mFile->read(file_entry_table.data(), file_entry_table.size());
|
{
|
||||||
|
file_entry_table = tc::ByteData(tc::io::IOUtil::castInt64ToSize(mRomfsHeader.file_entry.size.unwrap()));
|
||||||
|
mFile->seek(mRomfsHeader.file_entry.offset.unwrap(), tc::io::SeekOrigin::Begin);
|
||||||
|
mFile->read(file_entry_table.data(), file_entry_table.size());
|
||||||
|
}
|
||||||
|
|
||||||
// count dir num
|
// count dir num
|
||||||
mDirNum = 0;
|
mDirNum = 0;
|
||||||
|
|
Loading…
Reference in a new issue