summaryrefslogtreecommitdiff
path: root/src/nw4r/ut/ut_binaryFileFormat.cpp
blob: 1b62b51c2bc6a255a50bd13d88df4cc1e12ae408 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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