mirror of
https://github.com/jakcron/nstool
synced 2024-11-15 02:06:40 +00:00
[nstool] Fix bug in UserSettings where NSO files were incorrectly identified as NACP.
This commit is contained in:
parent
2c328c40b1
commit
61c3cb8cf3
1 changed files with 13 additions and 7 deletions
|
@ -626,7 +626,7 @@ FileType UserSettings::getFileTypeFromString(const std::string& type_str)
|
|||
|
||||
FileType UserSettings::determineFileTypeFromFile(const std::string& path)
|
||||
{
|
||||
static const size_t kMaxReadSize = 0x4000;
|
||||
static const size_t kMaxReadSize = 0x5000;
|
||||
FileType file_type = FILE_INVALID;
|
||||
fnd::SimpleFile file;
|
||||
fnd::Vec<byte_t> scratch;
|
||||
|
@ -640,6 +640,8 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
|
|||
// close file
|
||||
file.close();
|
||||
|
||||
fnd::SimpleTextOutput::hxdStyleDump(scratch.data(), 0x100);
|
||||
|
||||
// _TYPE_PTR resolves to a pointer of type 'st' located at scratch.data()
|
||||
#define _TYPE_PTR(st) ((st*)(scratch.data()))
|
||||
#define _ASSERT_SIZE(sz) (scratch.size() >= (sz))
|
||||
|
@ -662,12 +664,6 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
|
|||
// test nca
|
||||
else if (determineValidNcaFromSample(scratch))
|
||||
file_type = FILE_NCA;
|
||||
// test cnmt
|
||||
else if (determineValidCnmtFromSample(scratch))
|
||||
file_type = FILE_CNMT;
|
||||
// test nacp
|
||||
else if (determineValidNacpFromSample(scratch))
|
||||
file_type = FILE_NACP;
|
||||
// test nso
|
||||
else if (_ASSERT_SIZE(sizeof(nn::hac::sNsoHeader)) && _TYPE_PTR(nn::hac::sNsoHeader)->st_magic.get() == nn::hac::nso::kNsoStructMagic)
|
||||
file_type = FILE_NSO;
|
||||
|
@ -683,6 +679,16 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
|
|||
// test hb asset
|
||||
else if (_ASSERT_SIZE(sizeof(nn::hac::sAssetHeader)) && _TYPE_PTR(nn::hac::sAssetHeader)->st_magic.get() == nn::hac::aset::kAssetStructMagic)
|
||||
file_type = FILE_HB_ASSET;
|
||||
|
||||
// do heuristics
|
||||
// test cnmt
|
||||
else if (determineValidCnmtFromSample(scratch))
|
||||
file_type = FILE_CNMT;
|
||||
// test nacp
|
||||
else if (determineValidNacpFromSample(scratch))
|
||||
file_type = FILE_NACP;
|
||||
|
||||
|
||||
// else unrecognised
|
||||
else
|
||||
file_type = FILE_INVALID;
|
||||
|
|
Loading…
Reference in a new issue