2014-06-24 04:00:39 +00:00
|
|
|
/* [MS-CFB] 2.6.4 Red-Black Tree */
|
2017-11-05 00:15:50 +00:00
|
|
|
function build_full_paths(FI/*:CFBFileIndex*/, FP/*:Array<string>*/, Paths/*:Array<string>*/)/*:void*/ {
|
2014-06-24 04:00:39 +00:00
|
|
|
var i = 0, L = 0, R = 0, C = 0, j = 0, pl = Paths.length;
|
2017-07-28 17:53:08 +00:00
|
|
|
var dad/*:Array<number>*/ = [], q/*:Array<number>*/ = [];
|
2014-06-24 04:00:39 +00:00
|
|
|
|
|
|
|
for(; i < pl; ++i) { dad[i]=q[i]=i; FP[i]=Paths[i]; }
|
|
|
|
|
|
|
|
for(; j < q.length; ++j) {
|
|
|
|
i = q[j];
|
|
|
|
L = FI[i].L; R = FI[i].R; C = FI[i].C;
|
|
|
|
if(dad[i] === i) {
|
|
|
|
if(L !== -1 /*NOSTREAM*/ && dad[L] !== L) dad[i] = dad[L];
|
|
|
|
if(R !== -1 && dad[R] !== R) dad[i] = dad[R];
|
|
|
|
}
|
|
|
|
if(C !== -1 /*NOSTREAM*/) dad[C] = i;
|
2019-07-20 22:10:48 +00:00
|
|
|
if(L !== -1 && i != dad[i]) { dad[L] = dad[i]; if(q.lastIndexOf(L) < j) q.push(L); }
|
|
|
|
if(R !== -1 && i != dad[i]) { dad[R] = dad[i]; if(q.lastIndexOf(R) < j) q.push(R); }
|
2014-06-24 04:00:39 +00:00
|
|
|
}
|
2018-03-05 03:49:40 +00:00
|
|
|
for(i=1; i < pl; ++i) if(dad[i] === i) {
|
2014-06-24 04:00:39 +00:00
|
|
|
if(R !== -1 /*NOSTREAM*/ && dad[R] !== R) dad[i] = dad[R];
|
|
|
|
else if(L !== -1 && dad[L] !== L) dad[i] = dad[L];
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=1; i < pl; ++i) {
|
|
|
|
if(FI[i].type === 0 /* unknown */) continue;
|
2018-12-12 18:50:04 +00:00
|
|
|
j = i;
|
2019-07-20 22:10:48 +00:00
|
|
|
if(j != dad[j]) do {
|
2014-06-24 04:00:39 +00:00
|
|
|
j = dad[j];
|
2018-12-12 18:50:04 +00:00
|
|
|
FP[i] = FP[j] + "/" + FP[i];
|
2019-07-20 22:10:48 +00:00
|
|
|
} while (j !== 0 && -1 !== dad[j] && j != dad[j]);
|
2018-12-12 18:50:04 +00:00
|
|
|
dad[i] = -1;
|
2014-06-24 04:00:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
FP[0] += "/";
|
|
|
|
for(i=1; i < pl; ++i) {
|
|
|
|
if(FI[i].type !== 2 /* stream */) FP[i] += "/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|