js-cfb/bits/50_init.js

13 lines
487 B
JavaScript
Raw Normal View History

2017-09-14 21:14:22 +00:00
function init_cfb(cfb/*:CFBContainer*/, opts/*:?any*/)/*:void*/ {
var o = opts || {}, root = o.root || "Root Entry";
if(!cfb.FullPaths) cfb.FullPaths = [];
if(!cfb.FileIndex) cfb.FileIndex = [];
if(cfb.FullPaths.length !== cfb.FileIndex.length) throw new Error("inconsistent CFB structure");
if(cfb.FullPaths.length === 0) {
cfb.FullPaths[0] = root + "/";
cfb.FileIndex[0] = ({ name: root, type: 5 }/*:any*/);
}
if(o.CLSID) cfb.FileIndex[0].clsid = o.CLSID;
seed_cfb(cfb);
}