diff options
| author | Elijah Thomas <42302100+elijah-thomas774@users.noreply.github.com> | 2024-05-04 20:39:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-04 20:39:58 -0400 |
| commit | 80477fac196f32d0628c8a552f623e4cb0b9a7f8 (patch) | |
| tree | 7fc110d0bcb2e7a16dada39b2ca9b9964527bd20 /src/nw4r/ut/ut_binaryFileFormat.cpp | |
| parent | f3d89e071332ce13154d0a47e365f548ce4e4f65 (diff) | |
| parent | d45f347410a7a72f4cadef3bf84a1d0e9f72c1b3 (diff) | |
Merge pull request #22 from elijah-thomas774/ut_binaryFileFormat
ut_binaryFileFormat
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 |
