diff --git a/bits/21_ziputils.js b/bits/21_ziputils.js index e897a38..bf600b5 100644 --- a/bits/21_ziputils.js +++ b/bits/21_ziputils.js @@ -61,7 +61,7 @@ function getzipbin(zip, file/*:string*/, safe/*:?boolean*/)/*:any*/ { function zipentries(zip) { var k = zip.FullPaths || keys(zip.files), o = []; - for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i]); + for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i].replace(/^Root Entry[\/]/, "")); return o.sort(); } diff --git a/bits/88_write.js b/bits/88_write.js index fc580f6..97db769 100644 --- a/bits/88_write.js +++ b/bits/88_write.js @@ -47,7 +47,7 @@ function write_zip_type(wb/*:Workbook*/, opts/*:?WriteOpts*/)/*:any*/ { case "file": oopts.type = has_buf ? "nodebuffer" : "string"; break; default: throw new Error("Unrecognized type " + o.type); } - var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: /*::(*/{"nodebuffer": "buffer", "string": "binary"}/*:: :any)*/[oopts.type] || oopts.type}) : z.generate(oopts); + var out = z.FullPaths ? CFB.write(z, {fileType:"zip", type: /*::(*/{"nodebuffer": "buffer", "string": "binary"}/*:: :any)*/[oopts.type] || oopts.type, compression: !!o.compression}) : z.generate(oopts); if(typeof Deno !== "undefined" && typeof out == "string") out = new Uint8Array(s2ab(out)); /*jshint -W083 */ if(o.password && typeof encrypt_agile !== 'undefined') return write_cfb_ctr(encrypt_agile(out, o.password), o); // eslint-disable-line no-undef diff --git a/mini.lst b/mini.lst index 8213e20..941d944 100644 --- a/mini.lst +++ b/mini.lst @@ -1,6 +1,6 @@ bits/00_header.js bits/01_version.js -misc/02_codepage.js +bits/02_codepage.js bits/03_consts.js bits/04_base64.js bits/05_buf.js @@ -10,7 +10,7 @@ bits/11_ssfutils.js bits/18_cfb.js bits/19_fsutils.js bits/20_jsutils.js -misc/21_ziputils.js +bits/21_ziputils.js bits/22_xmlutils.js bits/23_binutils.js bits/24_hoppers.js diff --git a/misc/21_ziputils.js b/misc/21_ziputils.js deleted file mode 100644 index dd0cd51..0000000 --- a/misc/21_ziputils.js +++ /dev/null @@ -1,93 +0,0 @@ -function getdatastr(data)/*:?string*/ { - if(!data) return null; - if(data.data) return debom(data.data); - if(data.asNodeBuffer && has_buf) return debom(data.asNodeBuffer().toString('binary')); - if(data.asBinary) return debom(data.asBinary()); - if(data._data && data._data.getContent) return debom(cc2str(Array.prototype.slice.call(data._data.getContent(),0))); - if(data.content && data.type) return debom(cc2str(data.content)); - return null; -} - -function getdatabin(data) { - if(!data) return null; - if(data.data) return char_codes(data.data); - if(data.asNodeBuffer && has_buf) return data.asNodeBuffer(); - if(data._data && data._data.getContent) { - var o = data._data.getContent(); - if(typeof o == "string") return char_codes(o); - return Array.prototype.slice.call(o); - } - if(data.content && data.type) return data.content; - return null; -} - -function getdata(data) { return (data && data.name.slice(-4) === ".bin") ? getdatabin(data) : getdatastr(data); } - -/* Part 2 Section 10.1.2 "Mapping Content Types" Names are case-insensitive */ -/* OASIS does not comment on filename case sensitivity */ -function safegetzipfile(zip, file/*:string*/) { - var k = zip.FullPaths || keys(zip.files); - var f = file.toLowerCase().replace(/[\/]/g, '\\'), g = f.replace(/\\/g,'\/'); - for(var i=0; i