ut_binaryFileFormat Matching

This commit is contained in:
elijah-thomas774
2024-05-04 20:35:32 -04:00
parent 1ecdfe9a4d
commit 93a9b77d42
5 changed files with 34 additions and 3 deletions
+28
View File
@@ -0,0 +1,28 @@
#include <nw4r/ut/ut_binaryFileFormat.h>
namespace nw4r {
namespace ut {
/* 8042a9e0 */
bool IsValidBinaryFile(const BinaryFileHeader *header, unsigned long magic, u16 version, u16 numBlocks) {
if (header->magic != magic) {
return false;
}
if (header->byteOrder != 0xFEFF) {
return false;
}
if (header->version != version) {
return false;
}
if (header->fileSize < (numBlocks * sizeof(BinaryBlockHeader) + sizeof(BinaryFileHeader))) {
return false;
}
if (header->numBlocks < numBlocks) {
return false;
}
return true;
}
} // namespace ut
} // namespace nw4r