summaryrefslogtreecommitdiff
path: root/src/nw4r/ut/ut_binaryFileFormat.cpp
diff options
context:
space:
mode:
authorelijah-thomas774 <elijahthomas774@gmail.com>2024-05-04 22:01:14 -0400
committerelijah-thomas774 <elijahthomas774@gmail.com>2024-05-04 22:01:14 -0400
commite4ea7a75d9a0650495581fd1b03e380900b96d87 (patch)
tree19f82092d8b9e773aafe91e7c0cdf41e50df577b /src/nw4r/ut/ut_binaryFileFormat.cpp
parent3d4d5ea068876e0a3df7ea295fbd1245d3d85c41 (diff)
parent80477fac196f32d0628c8a552f623e4cb0b9a7f8 (diff)
Merge branch 'main' of https://github.com/lepelog/ss-dtk
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