Hi. I try to check a binary file that I created myself with my own structure. Okteta can validate the binary file against a defined structure. I can already create a simple structure file and use it. But my data format have a map that can contain a variable count of key-values pairs. First is a int32 for the count, then (int32-int32) pairs x the count red before.
I tried something like this without success:
function init() {
var chunksIndex = struct({
size: uint32()
});
chunksIndex.updateFunc = updateChunksIndex;
var map = {
"chunksIndex": chunksIndex
};
var obj = struct(map);
obj.byteOrder = "big-endian";
return obj;
}
function updateChunksIndex(root) {
var sizeValue = this.size.value;
var map = {
size: uint32()
};
for (var i = 0; i < sizeValue; i++) {
map.set(struct({
pos: uint32(),
size: uint32()
}));
}
this = struct(map);
}