41 static const std::vector<std::string> chunks =
44 "PFID",
"SFID",
"AFID",
"BFID",
"MD21",
45 "TXAC",
"EXPT",
"EXP2",
"PABC",
"PADC",
46 "PSBC",
"PEDC",
"SKID",
"TXID",
"LDV1",
48 "AFM2",
"AFSA",
"AFSB",
49 "SKL1",
"SKA1",
"SKB1",
"SKS1",
"SKPD",
61 inline bool isChunked(
const unsigned char* data,
size_t dataSize)
69 const std::string magic(header.magic, 4);
71 if (std::find(known.begin(), known.end(), magic) == known.end())
75 return (
sizeof(
ChunkHeader) + header.size) <= dataSize;
86 inline std::vector<ChunkInfo>
parse(
const unsigned char* data,
size_t dataSize)
88 std::vector<ChunkInfo> result;
97 std::memcpy(&header, data + offset,
sizeof(
ChunkHeader));
101 if (offset + header.size > dataSize)
105 info.
magic = std::string(header.magic, 4);
107 info.
size = header.size;
108 result.push_back(std::move(info));
110 offset += header.size;
Standalone utility for parsing WoW chunk-based file formats.
const std::vector< std::string > & knownFirstChunks()
bool isChunked(const unsigned char *data, size_t dataSize)
Determine whether a buffer begins with a known chunked-file header.
std::vector< ChunkInfo > parse(const unsigned char *data, size_t dataSize)
Parse all top-level chunks from a buffer.
Runtime representation of a single parsed chunk.
std::string magic
Four-character chunk identifier.
uint32_t start
Byte offset of the chunk data (after the header).
uint32_t size
Size of the chunk data in bytes.