summaryrefslogtreecommitdiff
path: root/src/nw4r/ut/ut_binaryFileFormat.cpp
diff options
context:
space:
mode:
authorelijah-thomas774 <elijahthomas774@gmail.com>2024-05-04 20:35:32 -0400
committerelijah-thomas774 <elijahthomas774@gmail.com>2024-05-04 20:35:32 -0400
commit93a9b77d427393cafbe2dab2dda72ef67956a2f6 (patch)
treecfccd319cfac450c2d3bc96170aa17cb526ae589 /src/nw4r/ut/ut_binaryFileFormat.cpp
parent1ecdfe9a4dfdd429c04424d77a9c0e6c148832a1 (diff)
ut_binaryFileFormat Matching
Diffstat (limited to 'src/nw4r/ut/ut_binaryFileFormat.cpp')
-rw-r--r--src/nw4r/ut/ut_binaryFileFormat.cpp28
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