diff options
Diffstat (limited to 'src/nw4r/ut/ut_binaryFileFormat.cpp')
| -rw-r--r-- | src/nw4r/ut/ut_binaryFileFormat.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/nw4r/ut/ut_binaryFileFormat.cpp b/src/nw4r/ut/ut_binaryFileFormat.cpp new file mode 100644 index 00000000..1b62b51c --- /dev/null +++ b/src/nw4r/ut/ut_binaryFileFormat.cpp @@ -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 |
