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;
|
|
|
|
if(L !== -1) { dad[L] = dad[i]; q.push(L); }
|
|
|
|
if(R !== -1) { dad[R] = dad[i]; q.push(R); }
|
|
|
|
}
|
|
|
|
for(i=1; i !== pl; ++i) if(dad[i] === i) {
|
|
|
|
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;
|
|
|
|
j = dad[i];
|
|
|
|
if(j === 0) FP[i] = FP[0] + "/" + FP[i];
|
2017-08-09 06:50:59 +00:00
|
|
|
else while(j !== 0 && j !== dad[j]) {
|
2014-06-24 04:00:39 +00:00
|
|
|
FP[i] = FP[j] + "/" + FP[i];
|
|
|
|
j = dad[j];
|
|
|
|
}
|
|
|
|
dad[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
FP[0] += "/";
|
|
|
|
for(i=1; i < pl; ++i) {
|
|
|
|
if(FI[i].type !== 2 /* stream */) FP[i] += "/";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|