2017-09-14 21:14:22 +00:00
|
|
|
/* [MS-CFB] 2.6.4 (Unicode 3.0.1 case conversion) */
|
2017-08-09 06:50:59 +00:00
|
|
|
function find(cfb/*:CFBContainer*/, path/*:string*/)/*:?CFBEntry*/ {
|
2017-09-14 21:14:22 +00:00
|
|
|
var UCFullPaths/*:Array<string>*/ = cfb.FullPaths.map(function(x) { return x.toUpperCase(); });
|
|
|
|
var UCPaths/*:Array<string>*/ = UCFullPaths.map(function(x) { var y = x.split("/"); return y[y.length - (x.slice(-1) == "/" ? 2 : 1)]; });
|
|
|
|
var k/*:boolean*/ = false;
|
|
|
|
if(path.charCodeAt(0) === 47 /* "/" */) { k = true; path = UCFullPaths[0].slice(0, -1) + path; }
|
|
|
|
else k = path.indexOf("/") !== -1;
|
|
|
|
var UCPath/*:string*/ = path.toUpperCase();
|
|
|
|
var w/*:number*/ = k === true ? UCFullPaths.indexOf(UCPath) : UCPaths.indexOf(UCPath);
|
|
|
|
if(w !== -1) return cfb.FileIndex[w];
|
|
|
|
|
2018-03-05 03:49:40 +00:00
|
|
|
var m = !UCPath.match(chr1);
|
|
|
|
UCPath = UCPath.replace(chr0,'');
|
|
|
|
if(m) UCPath = UCPath.replace(chr1,'!');
|
2017-09-14 21:14:22 +00:00
|
|
|
for(w = 0; w < UCFullPaths.length; ++w) {
|
2018-03-05 03:49:40 +00:00
|
|
|
if((m ? UCFullPaths[w].replace(chr1,'!') : UCFullPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
|
|
|
|
if((m ? UCPaths[w].replace(chr1,'!') : UCPaths[w]).replace(chr0,'') == UCPath) return cfb.FileIndex[w];
|
2017-09-14 21:14:22 +00:00
|
|
|
}
|
|
|
|
return null;
|
2017-08-09 06:50:59 +00:00
|
|
|
}
|