js-cfb/bits/56_dirtree.js

26 lines
671 B
JavaScript
Raw Normal View History

var now = new Date(1987, 1, 19), j = 0;
// Track which names exist
var fullPaths = Object.create ? Object.create(null) : {};
2017-09-14 21:14:22 +00:00
var data/*:Array<[string, CFBEntry]>*/ = [];
for(i = 0; i < cfb.FullPaths.length; ++i) {
fullPaths[cfb.FullPaths[i]] = true;
2017-09-14 21:14:22 +00:00
if(cfb.FileIndex[i].type === 0) continue;
data.push([cfb.FullPaths[i], cfb.FileIndex[i]]);
}
for(i = 0; i < data.length; ++i) {
var dad = dirname(data[i][0]);
s = fullPaths[dad];
if(!s) {
data.push([dad, ({
name: filename(dad).replace("/",""),
type: 1,
clsid: HEADER_CLSID,
ct: now, mt: now,
content: null
}/*:any*/)]);
// Add name to set
fullPaths[dad] = true;
}
2017-09-14 21:14:22 +00:00
}