mirror of
https://github.com/jakcron/nstool
synced 2024-11-22 21:49:30 +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)
|
FileType UserSettings::determineFileTypeFromFile(const std::string& path)
|
||||||
{
|
{
|
||||||
static const size_t kMaxReadSize = 0x4000;
|
static const size_t kMaxReadSize = 0x5000;
|
||||||
FileType file_type = FILE_INVALID;
|
FileType file_type = FILE_INVALID;
|
||||||
fnd::SimpleFile file;
|
fnd::SimpleFile file;
|
||||||
fnd::Vec<byte_t> scratch;
|
fnd::Vec<byte_t> scratch;
|
||||||
|
@ -640,6 +640,8 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
|
||||||
// close file
|
// close file
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
fnd::SimpleTextOutput::hxdStyleDump(scratch.data(), 0x100);
|
||||||
|
|
||||||
// _TYPE_PTR resolves to a pointer of type 'st' located at scratch.data()
|
// _TYPE_PTR resolves to a pointer of type 'st' located at scratch.data()
|
||||||
#define _TYPE_PTR(st) ((st*)(scratch.data()))
|
#define _TYPE_PTR(st) ((st*)(scratch.data()))
|
||||||
#define _ASSERT_SIZE(sz) (scratch.size() >= (sz))
|
#define _ASSERT_SIZE(sz) (scratch.size() >= (sz))
|
||||||
|
@ -662,12 +664,6 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
|
||||||
// test nca
|
// test nca
|
||||||
else if (determineValidNcaFromSample(scratch))
|
else if (determineValidNcaFromSample(scratch))
|
||||||
file_type = FILE_NCA;
|
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
|
// test nso
|
||||||
else if (_ASSERT_SIZE(sizeof(nn::hac::sNsoHeader)) && _TYPE_PTR(nn::hac::sNsoHeader)->st_magic.get() == nn::hac::nso::kNsoStructMagic)
|
else if (_ASSERT_SIZE(sizeof(nn::hac::sNsoHeader)) && _TYPE_PTR(nn::hac::sNsoHeader)->st_magic.get() == nn::hac::nso::kNsoStructMagic)
|
||||||
file_type = FILE_NSO;
|
file_type = FILE_NSO;
|
||||||
|
@ -683,6 +679,16 @@ FileType UserSettings::determineFileTypeFromFile(const std::string& path)
|
||||||
// test hb asset
|
// test hb asset
|
||||||
else if (_ASSERT_SIZE(sizeof(nn::hac::sAssetHeader)) && _TYPE_PTR(nn::hac::sAssetHeader)->st_magic.get() == nn::hac::aset::kAssetStructMagic)
|
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;
|
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 unrecognised
|
||||||
else
|
else
|
||||||
file_type = FILE_INVALID;
|
file_type = FILE_INVALID;
|
||||||
|
|
Loading…
Reference in a new issue