summaryrefslogtreecommitdiff
path: root/src/nw4r/ut/ut_binaryFileFormat.cpp
blob: c27c28671d68469fdb3f3c2e0043affb3cc76a49 (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
#include "nw4r/ut/ut_binaryFileFormat.h"

namespace nw4r {
namespace ut {

bool IsValidBinaryFile(const BinaryFileHeader *header, u32 magic, u16 version, u16 numBlocks) {
    if (header->signature != 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