Use map when creating CFB storage list (fixes #12)
This commit is contained in:
parent
76e4603fa5
commit
4c7b78f9dc
@ -1,19 +1,25 @@
|
||||
var now = new Date(1987, 1, 19), j = 0;
|
||||
// Track which names exist
|
||||
var fullPaths = Object.create ? Object.create(null) : {};
|
||||
var data/*:Array<[string, CFBEntry]>*/ = [];
|
||||
for(i = 0; i < cfb.FullPaths.length; ++i) {
|
||||
fullPaths[cfb.FullPaths[i]] = true;
|
||||
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 = false;
|
||||
for(j = 0; j < data.length; ++j) if(data[j][0] === dad) s = true;
|
||||
if(!s) data.push([dad, ({
|
||||
name: filename(dad).replace("/",""),
|
||||
type: 1,
|
||||
clsid: HEADER_CLSID,
|
||||
ct: now, mt: now,
|
||||
content: null
|
||||
}/*:any*/)]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
24
cfb.flow.js
24
cfb.flow.js
@ -756,22 +756,28 @@ function rebuild_cfb(cfb/*:CFBContainer*/, f/*:?boolean*/)/*:void*/ {
|
||||
if(!gc && !f) return;
|
||||
|
||||
var now = new Date(1987, 1, 19), j = 0;
|
||||
// Track which names exist
|
||||
var fullPaths = Object.create ? Object.create(null) : {};
|
||||
var data/*:Array<[string, CFBEntry]>*/ = [];
|
||||
for(i = 0; i < cfb.FullPaths.length; ++i) {
|
||||
fullPaths[cfb.FullPaths[i]] = true;
|
||||
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 = false;
|
||||
for(j = 0; j < data.length; ++j) if(data[j][0] === dad) s = true;
|
||||
if(!s) data.push([dad, ({
|
||||
name: filename(dad).replace("/",""),
|
||||
type: 1,
|
||||
clsid: HEADER_CLSID,
|
||||
ct: now, mt: now,
|
||||
content: null
|
||||
}/*:any*/)]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
data.sort(function(x,y) { return namecmp(x[0], y[0]); });
|
||||
|
24
cfb.js
24
cfb.js
@ -738,22 +738,28 @@ function rebuild_cfb(cfb, f) {
|
||||
if(!gc && !f) return;
|
||||
|
||||
var now = new Date(1987, 1, 19), j = 0;
|
||||
// Track which names exist
|
||||
var fullPaths = Object.create ? Object.create(null) : {};
|
||||
var data = [];
|
||||
for(i = 0; i < cfb.FullPaths.length; ++i) {
|
||||
fullPaths[cfb.FullPaths[i]] = true;
|
||||
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 = false;
|
||||
for(j = 0; j < data.length; ++j) if(data[j][0] === dad) s = true;
|
||||
if(!s) data.push([dad, ({
|
||||
name: filename(dad).replace("/",""),
|
||||
type: 1,
|
||||
clsid: HEADER_CLSID,
|
||||
ct: now, mt: now,
|
||||
content: null
|
||||
})]);
|
||||
s = fullPaths[dad];
|
||||
if(!s) {
|
||||
data.push([dad, ({
|
||||
name: filename(dad).replace("/",""),
|
||||
type: 1,
|
||||
clsid: HEADER_CLSID,
|
||||
ct: now, mt: now,
|
||||
content: null
|
||||
})]);
|
||||
// Add name to set
|
||||
fullPaths[dad] = true;
|
||||
}
|
||||
}
|
||||
|
||||
data.sort(function(x,y) { return namecmp(x[0], y[0]); });
|
||||
|
@ -604,22 +604,28 @@ function rebuild_cfb(cfb/*:CFBContainer*/, f/*:?boolean*/)/*:void*/ {
|
||||
if(!gc && !f) return;
|
||||
|
||||
var now = new Date(1987, 1, 19), j = 0;
|
||||
// Track which names exist
|
||||
var fullPaths = Object.create ? Object.create(null) : {};
|
||||
var data/*:Array<[string, CFBEntry]>*/ = [];
|
||||
for(i = 0; i < cfb.FullPaths.length; ++i) {
|
||||
fullPaths[cfb.FullPaths[i]] = true;
|
||||
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 = false;
|
||||
for(j = 0; j < data.length; ++j) if(data[j][0] === dad) s = true;
|
||||
if(!s) data.push([dad, ({
|
||||
name: filename(dad).replace("/",""),
|
||||
type: 1,
|
||||
clsid: HEADER_CLSID,
|
||||
ct: now, mt: now,
|
||||
content: null
|
||||
}/*:any*/)]);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
data.sort(function(x,y) { return namecmp(x[0], y[0]); });
|
||||
|
24
xlscfb.js
24
xlscfb.js
@ -570,22 +570,28 @@ function rebuild_cfb(cfb, f) {
|
||||
if(!gc && !f) return;
|
||||
|
||||
var now = new Date(1987, 1, 19), j = 0;
|
||||
// Track which names exist
|
||||
var fullPaths = Object.create ? Object.create(null) : {};
|
||||
var data = [];
|
||||
for(i = 0; i < cfb.FullPaths.length; ++i) {
|
||||
fullPaths[cfb.FullPaths[i]] = true;
|
||||
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 = false;
|
||||
for(j = 0; j < data.length; ++j) if(data[j][0] === dad) s = true;
|
||||
if(!s) data.push([dad, ({
|
||||
name: filename(dad).replace("/",""),
|
||||
type: 1,
|
||||
clsid: HEADER_CLSID,
|
||||
ct: now, mt: now,
|
||||
content: null
|
||||
})]);
|
||||
s = fullPaths[dad];
|
||||
if(!s) {
|
||||
data.push([dad, ({
|
||||
name: filename(dad).replace("/",""),
|
||||
type: 1,
|
||||
clsid: HEADER_CLSID,
|
||||
ct: now, mt: now,
|
||||
content: null
|
||||
})]);
|
||||
// Add name to set
|
||||
fullPaths[dad] = true;
|
||||
}
|
||||
}
|
||||
|
||||
data.sort(function(x,y) { return namecmp(x[0], y[0]); });
|
||||
|
Loading…
Reference in New Issue
Block a user