xiejun
2023-08-23 205056bc17023dd44e6d262cfe78b6e146ee2f20
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function getdata(data) {
    if(!data) return null;
    if(data.name.substr(-4) === ".bin") {
        if(data.data) return char_codes(data.data);
        if(data.asNodeBuffer && has_buf) return data.asNodeBuffer();
        if(data._data && data._data.getContent) return Array.prototype.slice.call(data._data.getContent());
    } else {
        if(data.data) return data.name.substr(-4) !== ".bin" ? debom_xml(data.data) : char_codes(data.data);
        if(data.asNodeBuffer && has_buf) return debom_xml(data.asNodeBuffer().toString('binary'));
        if(data.asBinary) return debom_xml(data.asBinary());
        if(data._data && data._data.getContent) return debom_xml(cc2str(Array.prototype.slice.call(data._data.getContent(),0)));
    }
    return null;
}
 
function safegetzipfile(zip, file) {
    var f = file; if(zip.files[f]) return zip.files[f];
 
    var lowerCaseFiles = {};
    for (var key in zip.files) {
        lowerCaseFiles[key.toLowerCase()] = zip.files[key];
    }
 
    f = file.toLowerCase(); if(lowerCaseFiles[f]) return lowerCaseFiles[f];
    f = f.replace(/\//g,'\\'); if(lowerCaseFiles[f]) return lowerCaseFiles[f];
    return null;
}
 
function getzipfile(zip, file) {
    var o = safegetzipfile(zip, file);
    if(o == null) throw new Error("Cannot find file " + file + " in zip");
    return o;
}
 
function getzipdata(zip, file, safe) {
    if(!safe) return getdata(getzipfile(zip, file));
    if(!file) return null;
    try { return getzipdata(zip, file); } catch(e) { return null; }
}
 
var _fs, jszip;
if(typeof JSZip !== 'undefined') jszip = JSZip;
if (typeof exports !== 'undefined') {
    if (typeof module !== 'undefined' && module.exports) {
        if(has_buf && typeof jszip === 'undefined') jszip = require('js'+'zip');
        if(typeof jszip === 'undefined') jszip = require('./js'+'zip').JSZip;
        _fs = require('f'+'s');
    }
}