UNPKG

pizzip

Version:

Create, read and edit .zip files synchronously with Javascript

162 lines (121 loc) 152 kB
/* * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). * This devtool is neither made for production nor for readable output files. * It uses "eval()" calls to create a separate source file in the browser devtools. * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) * or disable the default devtool with "devtool: false". * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). */ /******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./es6/arrayReader.js": /*!****************************!*\ !*** ./es6/arrayReader.js ***! \****************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\nvar DataReader = __webpack_require__(/*! ./dataReader.js */ \"./es6/dataReader.js\");\nfunction ArrayReader(data) {\n if (data) {\n this.data = data;\n this.length = this.data.length;\n this.index = 0;\n this.zero = 0;\n for (var i = 0; i < this.data.length; i++) {\n data[i] &= data[i];\n }\n }\n}\nArrayReader.prototype = new DataReader();\n/**\n * @see DataReader.byteAt\n */\nArrayReader.prototype.byteAt = function (i) {\n return this.data[this.zero + i];\n};\n/**\n * @see DataReader.lastIndexOfSignature\n */\nArrayReader.prototype.lastIndexOfSignature = function (sig) {\n var sig0 = sig.charCodeAt(0),\n sig1 = sig.charCodeAt(1),\n sig2 = sig.charCodeAt(2),\n sig3 = sig.charCodeAt(3);\n for (var i = this.length - 4; i >= 0; --i) {\n if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {\n return i - this.zero;\n }\n }\n return -1;\n};\n/**\n * @see DataReader.readData\n */\nArrayReader.prototype.readData = function (size) {\n this.checkOffset(size);\n if (size === 0) {\n return [];\n }\n var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n this.index += size;\n return result;\n};\nmodule.exports = ArrayReader;\n\n//# sourceURL=webpack://PizZip/./es6/arrayReader.js?"); /***/ }), /***/ "./es6/base64.js": /*!***********************!*\ !*** ./es6/base64.js ***! \***********************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; eval("\n\n// private property\nvar _keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\n\n// public method for encoding\nexports.encode = function (input) {\n var output = \"\";\n var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n var i = 0;\n while (i < input.length) {\n chr1 = input.charCodeAt(i++);\n chr2 = input.charCodeAt(i++);\n chr3 = input.charCodeAt(i++);\n enc1 = chr1 >> 2;\n enc2 = (chr1 & 3) << 4 | chr2 >> 4;\n enc3 = (chr2 & 15) << 2 | chr3 >> 6;\n enc4 = chr3 & 63;\n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n } else if (isNaN(chr3)) {\n enc4 = 64;\n }\n output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4);\n }\n return output;\n};\n\n// public method for decoding\nexports.decode = function (input) {\n var output = \"\";\n var chr1, chr2, chr3;\n var enc1, enc2, enc3, enc4;\n var i = 0;\n input = input.replace(/[^A-Za-z0-9\\+\\/\\=]/g, \"\");\n while (i < input.length) {\n enc1 = _keyStr.indexOf(input.charAt(i++));\n enc2 = _keyStr.indexOf(input.charAt(i++));\n enc3 = _keyStr.indexOf(input.charAt(i++));\n enc4 = _keyStr.indexOf(input.charAt(i++));\n chr1 = enc1 << 2 | enc2 >> 4;\n chr2 = (enc2 & 15) << 4 | enc3 >> 2;\n chr3 = (enc3 & 3) << 6 | enc4;\n output += String.fromCharCode(chr1);\n if (enc3 !== 64) {\n output += String.fromCharCode(chr2);\n }\n if (enc4 !== 64) {\n output += String.fromCharCode(chr3);\n }\n }\n return output;\n};\n\n//# sourceURL=webpack://PizZip/./es6/base64.js?"); /***/ }), /***/ "./es6/compressedObject.js": /*!*********************************!*\ !*** ./es6/compressedObject.js ***! \*********************************/ /***/ ((module) => { "use strict"; eval("\n\nfunction CompressedObject() {\n this.compressedSize = 0;\n this.uncompressedSize = 0;\n this.crc32 = 0;\n this.compressionMethod = null;\n this.compressedContent = null;\n}\nCompressedObject.prototype = {\n /**\n * Return the decompressed content in an unspecified format.\n * The format will depend on the decompressor.\n * @return {Object} the decompressed content.\n */\n getContent: function getContent() {\n return null; // see implementation\n },\n /**\n * Return the compressed content in an unspecified format.\n * The format will depend on the compressed conten source.\n * @return {Object} the compressed content.\n */\n getCompressedContent: function getCompressedContent() {\n return null; // see implementation\n }\n};\nmodule.exports = CompressedObject;\n\n//# sourceURL=webpack://PizZip/./es6/compressedObject.js?"); /***/ }), /***/ "./es6/compressions.js": /*!*****************************!*\ !*** ./es6/compressions.js ***! \*****************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; eval("\n\nexports.STORE = {\n magic: \"\\x00\\x00\",\n compress: function compress(content) {\n return content; // no compression\n },\n uncompress: function uncompress(content) {\n return content; // no compression\n },\n compressInputType: null,\n uncompressInputType: null\n};\nexports.DEFLATE = __webpack_require__(/*! ./flate.js */ \"./es6/flate.js\");\n\n//# sourceURL=webpack://PizZip/./es6/compressions.js?"); /***/ }), /***/ "./es6/crc32.js": /*!**********************!*\ !*** ./es6/crc32.js ***! \**********************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\nvar utils = __webpack_require__(/*! ./utils.js */ \"./es6/utils.js\");\n\n// prettier-ignore\nvar table = [0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D];\n\n/**\n *\n * Javascript crc32\n * http://www.webtoolkit.info/\n *\n */\nmodule.exports = function crc32(input, crc) {\n if (typeof input === \"undefined\" || !input.length) {\n return 0;\n }\n var isArray = utils.getTypeOf(input) !== \"string\";\n if (typeof crc == \"undefined\") {\n crc = 0;\n }\n var x = 0;\n var y = 0;\n var b = 0;\n crc ^= -1;\n for (var i = 0, iTop = input.length; i < iTop; i++) {\n b = isArray ? input[i] : input.charCodeAt(i);\n y = (crc ^ b) & 0xff;\n x = table[y];\n crc = crc >>> 8 ^ x;\n }\n return crc ^ -1;\n};\n\n//# sourceURL=webpack://PizZip/./es6/crc32.js?"); /***/ }), /***/ "./es6/dataReader.js": /*!***************************!*\ !*** ./es6/dataReader.js ***! \***************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\nvar utils = __webpack_require__(/*! ./utils.js */ \"./es6/utils.js\");\nfunction DataReader() {\n this.data = null; // type : see implementation\n this.length = 0;\n this.index = 0;\n this.zero = 0;\n}\nDataReader.prototype = {\n /**\n * Check that the offset will not go too far.\n * @param {string} offset the additional offset to check.\n * @throws {Error} an Error if the offset is out of bounds.\n */\n checkOffset: function checkOffset(offset) {\n this.checkIndex(this.index + offset);\n },\n /**\n * Check that the specifed index will not be too far.\n * @param {string} newIndex the index to check.\n * @throws {Error} an Error if the index is out of bounds.\n */\n checkIndex: function checkIndex(newIndex) {\n if (this.length < this.zero + newIndex || newIndex < 0) {\n throw new Error(\"End of data reached (data length = \" + this.length + \", asked index = \" + newIndex + \"). Corrupted zip ?\");\n }\n },\n /**\n * Change the index.\n * @param {number} newIndex The new index.\n * @throws {Error} if the new index is out of the data.\n */\n setIndex: function setIndex(newIndex) {\n this.checkIndex(newIndex);\n this.index = newIndex;\n },\n /**\n * Skip the next n bytes.\n * @param {number} n the number of bytes to skip.\n * @throws {Error} if the new index is out of the data.\n */\n skip: function skip(n) {\n this.setIndex(this.index + n);\n },\n /**\n * Get the byte at the specified index.\n * @param {number} i the index to use.\n * @return {number} a byte.\n */\n byteAt: function byteAt() {\n // see implementations\n },\n /**\n * Get the next number with a given byte size.\n * @param {number} size the number of bytes to read.\n * @return {number} the corresponding number.\n */\n readInt: function readInt(size) {\n var result = 0,\n i;\n this.checkOffset(size);\n for (i = this.index + size - 1; i >= this.index; i--) {\n result = (result << 8) + this.byteAt(i);\n }\n this.index += size;\n return result;\n },\n /**\n * Get the next string with a given byte size.\n * @param {number} size the number of bytes to read.\n * @return {string} the corresponding string.\n */\n readString: function readString(size) {\n return utils.transformTo(\"string\", this.readData(size));\n },\n /**\n * Get raw data without conversion, <size> bytes.\n * @param {number} size the number of bytes to read.\n * @return {Object} the raw data, implementation specific.\n */\n readData: function readData() {\n // see implementations\n },\n /**\n * Find the last occurence of a zip signature (4 bytes).\n * @param {string} sig the signature to find.\n * @return {number} the index of the last occurence, -1 if not found.\n */\n lastIndexOfSignature: function lastIndexOfSignature() {\n // see implementations\n },\n /**\n * Get the next date.\n * @return {Date} the date.\n */\n readDate: function readDate() {\n var dostime = this.readInt(4);\n return new Date((dostime >> 25 & 0x7f) + 1980,\n // year\n (dostime >> 21 & 0x0f) - 1,\n // month\n dostime >> 16 & 0x1f,\n // day\n dostime >> 11 & 0x1f,\n // hour\n dostime >> 5 & 0x3f,\n // minute\n (dostime & 0x1f) << 1); // second\n }\n};\nmodule.exports = DataReader;\n\n//# sourceURL=webpack://PizZip/./es6/dataReader.js?"); /***/ }), /***/ "./es6/defaults.js": /*!*************************!*\ !*** ./es6/defaults.js ***! \*************************/ /***/ ((__unused_webpack_module, exports) => { "use strict"; eval("\n\nexports.base64 = false;\nexports.binary = false;\nexports.dir = false;\nexports.createFolders = false;\nexports.date = null;\nexports.compression = null;\nexports.compressionOptions = null;\nexports.comment = null;\nexports.unixPermissions = null;\nexports.dosPermissions = null;\n\n//# sourceURL=webpack://PizZip/./es6/defaults.js?"); /***/ }), /***/ "./es6/deprecatedPublicUtils.js": /*!**************************************!*\ !*** ./es6/deprecatedPublicUtils.js ***! \**************************************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; eval("\n\nvar utils = __webpack_require__(/*! ./utils.js */ \"./es6/utils.js\");\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.string2binary = function (str) {\n return utils.string2binary(str);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.string2Uint8Array = function (str) {\n return utils.transformTo(\"uint8array\", str);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.uint8Array2String = function (array) {\n return utils.transformTo(\"string\", array);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.string2Blob = function (str) {\n var buffer = utils.transformTo(\"arraybuffer\", str);\n return utils.arrayBuffer2Blob(buffer);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.arrayBuffer2Blob = function (buffer) {\n return utils.arrayBuffer2Blob(buffer);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.transformTo = function (outputType, input) {\n return utils.transformTo(outputType, input);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.getTypeOf = function (input) {\n return utils.getTypeOf(input);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.checkSupport = function (type) {\n return utils.checkSupport(type);\n};\n\n/**\n * @deprecated\n * This value will be removed in a future version without replacement.\n */\nexports.MAX_VALUE_16BITS = utils.MAX_VALUE_16BITS;\n\n/**\n * @deprecated\n * This value will be removed in a future version without replacement.\n */\nexports.MAX_VALUE_32BITS = utils.MAX_VALUE_32BITS;\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.pretty = function (str) {\n return utils.pretty(str);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.findCompression = function (compressionMethod) {\n return utils.findCompression(compressionMethod);\n};\n\n/**\n * @deprecated\n * This function will be removed in a future version without replacement.\n */\nexports.isRegExp = function (object) {\n return utils.isRegExp(object);\n};\n\n//# sourceURL=webpack://PizZip/./es6/deprecatedPublicUtils.js?"); /***/ }), /***/ "./es6/flate.js": /*!**********************!*\ !*** ./es6/flate.js ***! \**********************/ /***/ ((__unused_webpack_module, exports, __webpack_require__) => { "use strict"; eval("\n\nvar USE_TYPEDARRAY = typeof Uint8Array !== \"undefined\" && typeof Uint16Array !== \"undefined\" && typeof Uint32Array !== \"undefined\";\nvar pako = __webpack_require__(/*! pako/dist/pako.es5.min.js */ \"./node_modules/pako/dist/pako.es5.min.js\");\nexports.uncompressInputType = USE_TYPEDARRAY ? \"uint8array\" : \"array\";\nexports.compressInputType = USE_TYPEDARRAY ? \"uint8array\" : \"array\";\nexports.magic = \"\\x08\\x00\";\nexports.compress = function (input, compressionOptions) {\n return pako.deflateRaw(input, {\n level: compressionOptions.level || -1 // default compression\n });\n};\nexports.uncompress = function (input) {\n return pako.inflateRaw(input);\n};\n\n//# sourceURL=webpack://PizZip/./es6/flate.js?"); /***/ }), /***/ "./es6/index.js": /*!**********************!*\ !*** ./es6/index.js ***! \**********************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\nvar base64 = __webpack_require__(/*! ./base64.js */ \"./es6/base64.js\");\n\n/**\nUsage:\n zip = new PizZip();\n zip.file(\"hello.txt\", \"Hello, World!\").file(\"tempfile\", \"nothing\");\n zip.folder(\"images\").file(\"smile.gif\", base64Data, {base64: true});\n zip.file(\"Xmas.txt\", \"Ho ho ho !\", {date : new Date(\"December 25, 2007 00:00:01\")});\n zip.remove(\"tempfile\");\n\n base64zip = zip.generate();\n\n**/\n\n/**\n * Representation a of zip file in js\n * @constructor\n * @param {String=|ArrayBuffer=|Uint8Array=} data the data to load, if any (optional).\n * @param {Object=} options the options for creating this objects (optional).\n */\nfunction PizZip(data, options) {\n // if this constructor is used without `new`, it adds `new` before itself:\n if (!(this instanceof PizZip)) {\n return new PizZip(data, options);\n }\n\n // object containing the files :\n // {\n // \"folder/\" : {...},\n // \"folder/data.txt\" : {...}\n // }\n this.files = {};\n this.comment = null;\n\n // Where we are in the hierarchy\n this.root = \"\";\n if (data) {\n this.load(data, options);\n }\n this.clone = function () {\n var _this = this;\n var newObj = new PizZip();\n Object.keys(this.files).forEach(function (file) {\n newObj.file(file, _this.files[file].asUint8Array());\n });\n return newObj;\n };\n this.shallowClone = function () {\n var newObj = new PizZip();\n for (var i in this) {\n if (typeof this[i] !== \"function\") {\n newObj[i] = this[i];\n }\n }\n return newObj;\n };\n}\nPizZip.prototype = __webpack_require__(/*! ./object.js */ \"./es6/object.js\");\nPizZip.prototype.load = __webpack_require__(/*! ./load.js */ \"./es6/load.js\");\nPizZip.support = __webpack_require__(/*! ./support.js */ \"./es6/support.js\");\nPizZip.defaults = __webpack_require__(/*! ./defaults.js */ \"./es6/defaults.js\");\n\n/**\n * @deprecated\n * This namespace will be removed in a future version without replacement.\n */\nPizZip.utils = __webpack_require__(/*! ./deprecatedPublicUtils.js */ \"./es6/deprecatedPublicUtils.js\");\nPizZip.base64 = {\n /**\n * @deprecated\n * This method will be removed in a future version without replacement.\n */\n encode: function encode(input) {\n return base64.encode(input);\n },\n /**\n * @deprecated\n * This method will be removed in a future version without replacement.\n */\n decode: function decode(input) {\n return base64.decode(input);\n }\n};\nPizZip.compressions = __webpack_require__(/*! ./compressions.js */ \"./es6/compressions.js\");\nmodule.exports = PizZip;\nmodule.exports[\"default\"] = PizZip;\n\n//# sourceURL=webpack://PizZip/./es6/index.js?"); /***/ }), /***/ "./es6/load.js": /*!*********************!*\ !*** ./es6/load.js ***! \*********************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\nvar base64 = __webpack_require__(/*! ./base64.js */ \"./es6/base64.js\");\nvar utf8 = __webpack_require__(/*! ./utf8.js */ \"./es6/utf8.js\");\nvar utils = __webpack_require__(/*! ./utils.js */ \"./es6/utils.js\");\nvar ZipEntries = __webpack_require__(/*! ./zipEntries.js */ \"./es6/zipEntries.js\");\nmodule.exports = function (data, options) {\n var i, input;\n options = utils.extend(options || {}, {\n base64: false,\n checkCRC32: false,\n optimizedBinaryString: false,\n createFolders: false,\n decodeFileName: utf8.utf8decode\n });\n if (options.base64) {\n data = base64.decode(data);\n }\n var zipEntries = new ZipEntries(data, options);\n var files = zipEntries.files;\n for (i = 0; i < files.length; i++) {\n input = files[i];\n this.file(input.fileNameStr, input.decompressed, {\n binary: true,\n optimizedBinaryString: true,\n date: input.date,\n dir: input.dir,\n comment: input.fileCommentStr.length ? input.fileCommentStr : null,\n unixPermissions: input.unixPermissions,\n dosPermissions: input.dosPermissions,\n createFolders: options.createFolders\n });\n }\n if (zipEntries.zipComment.length) {\n this.comment = zipEntries.zipComment;\n }\n return this;\n};\n\n//# sourceURL=webpack://PizZip/./es6/load.js?"); /***/ }), /***/ "./es6/nodeBuffer.js": /*!***************************!*\ !*** ./es6/nodeBuffer.js ***! \***************************/ /***/ ((module) => { "use strict"; eval("\n\nmodule.exports = function (data, encoding) {\n if (typeof data === \"number\") {\n return Buffer.alloc(data);\n }\n return Buffer.from(data, encoding);\n};\nmodule.exports.test = function (b) {\n return Buffer.isBuffer(b);\n};\n\n//# sourceURL=webpack://PizZip/./es6/nodeBuffer.js?"); /***/ }), /***/ "./es6/nodeBufferReader.js": /*!*********************************!*\ !*** ./es6/nodeBufferReader.js ***! \*********************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\nvar Uint8ArrayReader = __webpack_require__(/*! ./uint8ArrayReader.js */ \"./es6/uint8ArrayReader.js\");\nfunction NodeBufferReader(data) {\n this.data = data;\n this.length = this.data.length;\n this.index = 0;\n this.zero = 0;\n}\nNodeBufferReader.prototype = new Uint8ArrayReader();\n\n/**\n * @see DataReader.readData\n */\nNodeBufferReader.prototype.readData = function (size) {\n this.checkOffset(size);\n var result = this.data.slice(this.zero + this.index, this.zero + this.index + size);\n this.index += size;\n return result;\n};\nmodule.exports = NodeBufferReader;\n\n//# sourceURL=webpack://PizZip/./es6/nodeBufferReader.js?"); /***/ }), /***/ "./es6/object.js": /*!***********************!*\ !*** ./es6/object.js ***! \***********************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { "use strict"; eval("\n\nvar support = __webpack_require__(/*! ./support.js */ \"./es6/support.js\");\nvar utils = __webpack_require__(/*! ./utils.js */ \"./es6/utils.js\");\nvar _crc = __webpack_require__(/*! ./crc32.js */ \"./es6/crc32.js\");\nvar signature = __webpack_require__(/*! ./signature.js */ \"./es6/signature.js\");\nvar defaults = __webpack_require__(/*! ./defaults.js */ \"./es6/defaults.js\");\nvar base64 = __webpack_require__(/*! ./base64.js */ \"./es6/base64.js\");\nvar compressions = __webpack_require__(/*! ./compressions.js */ \"./es6/compressions.js\");\nvar CompressedObject = __webpack_require__(/*! ./compressedObject.js */ \"./es6/compressedObject.js\");\nvar nodeBuffer = __webpack_require__(/*! ./nodeBuffer.js */ \"./es6/nodeBuffer.js\");\nvar utf8 = __webpack_require__(/*! ./utf8.js */ \"./es6/utf8.js\");\nvar StringWriter = __webpack_require__(/*! ./stringWriter.js */ \"./es6/stringWriter.js\");\nvar Uint8ArrayWriter = __webpack_require__(/*! ./uint8ArrayWriter.js */ \"./es6/uint8ArrayWriter.js\");\n\n/**\n * Returns the raw data of a ZipObject, decompress the content if necessary.\n * @param {ZipObject} file the file to use.\n * @return {String|ArrayBuffer|Uint8Array|Buffer} the data.\n */\nfunction getRawData(file) {\n if (file._data instanceof CompressedObject) {\n file._data = file._data.getContent();\n file.options.binary = true;\n file.options.base64 = false;\n if (utils.getTypeOf(file._data) === \"uint8array\") {\n var copy = file._data;\n // when reading an arraybuffer, the CompressedObject mechanism will keep it and subarray() a Uint8Array.\n // if we request a file in the same format, we might get the same Uint8Array or its ArrayBuffer (the original zip file).\n file._data = new Uint8Array(copy.length);\n // with an empty Uint8Array, Opera fails with a \"Offset larger than array size\"\n if (copy.length !== 0) {\n file._data.set(copy, 0);\n }\n }\n }\n return file._data;\n}\n\n/**\n * Returns the data of a ZipObject in a binary form. If the content is an unicode string, encode it.\n * @param {ZipObject} file the file to use.\n * @return {String|ArrayBuffer|Uint8Array|Buffer} the data.\n */\nfunction getBinaryData(file) {\n var result = getRawData(file),\n type = utils.getTypeOf(result);\n if (type === \"string\") {\n if (!file.options.binary) {\n // unicode text !\n // unicode string => binary string is a painful process, check if we can avoid it.\n if (support.nodebuffer) {\n return nodeBuffer(result, \"utf-8\");\n }\n }\n return file.asBinary();\n }\n return result;\n}\n\n// return the actual prototype of PizZip\nvar out = {\n /**\n * Read an existing zip and merge the data in the current PizZip object.\n * The implementation is in pizzip-load.js, don't forget to include it.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} stream The stream to load\n * @param {Object} options Options for loading the stream.\n * options.base64 : is the stream in base64 ? default : false\n * @return {PizZip} the current PizZip object\n */\n load: function load() {\n throw new Error(\"Load method is not defined. Is the file pizzip-load.js included ?\");\n },\n /**\n * Filter nested files/folders with the specified function.\n * @param {Function} search the predicate to use :\n * function (relativePath, file) {...}\n * It takes 2 arguments : the relative path and the file.\n * @return {Array} An array of matching elements.\n */\n filter: function filter(search) {\n var result = [];\n var filename, relativePath, file, fileClone;\n for (filename in this.files) {\n if (!this.files.hasOwnProperty(filename)) {\n continue;\n }\n file = this.files[filename];\n // return a new object, don't let the user mess with our internal objects :)\n fileClone = new ZipObject(file.name, file._data, utils.extend(file.options));\n relativePath = filename.slice(this.root.length, filename.length);\n if (filename.slice(0, this.root.length) === this.root &&\n // the file is in the current root\n search(relativePath, fileClone)) {\n // and the file matches the function\n result.push(fileClone);\n }\n }\n return result;\n },\n /**\n * Add a file to the zip file, or search a file.\n * @param {string|RegExp} name The name of the file to add (if data is defined),\n * the name of the file to find (if no data) or a regex to match files.\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded\n * @param {Object} o File options\n * @return {PizZip|Object|Array} this PizZip object (when adding a file),\n * a file (when searching by string) or an array of files (when searching by regex).\n */\n file: function file(name, data, o) {\n if (arguments.length === 1) {\n if (utils.isRegExp(name)) {\n var regexp = name;\n return this.filter(function (relativePath, file) {\n return !file.dir && regexp.test(relativePath);\n });\n }\n // text\n return this.filter(function (relativePath, file) {\n return !file.dir && relativePath === name;\n })[0] || null;\n }\n // more than one argument : we have data !\n name = this.root + name;\n fileAdd.call(this, name, data, o);\n return this;\n },\n /**\n * Add a directory to the zip file, or search.\n * @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.\n * @return {PizZip} an object with the new directory as the root, or an array containing matching folders.\n */\n folder: function folder(arg) {\n if (!arg) {\n return this;\n }\n if (utils.isRegExp(arg)) {\n return this.filter(function (relativePath, file) {\n return file.dir && arg.test(relativePath);\n });\n }\n\n // else, name is a new folder\n var name = this.root + arg;\n var newFolder = folderAdd.call(this, name);\n\n // Allow chaining by returning a new object with this folder as the root\n var ret = this.shallowClone();\n ret.root = newFolder.name;\n return ret;\n },\n /**\n * Delete a file, or a directory and all sub-files, from the zip\n * @param {string} name the name of the file to delete\n * @return {PizZip} this PizZip object\n */\n remove: function remove(name) {\n name = this.root + name;\n var file = this.files[name];\n if (!file) {\n // Look for any folders\n if (name.slice(-1) !== \"/\") {\n name += \"/\";\n }\n file = this.files[name];\n }\n if (file && !file.dir) {\n // file\n delete this.files[name];\n } else {\n // maybe a folder, delete recursively\n var kids = this.filter(function (relativePath, file) {\n return file.name.slice(0, name.length) === name;\n });\n for (var i = 0; i < kids.length; i++) {\n delete this.files[kids[i].name];\n }\n }\n return this;\n },\n /**\n * Generate the complete zip file\n * @param {Object} options the options to generate the zip file :\n * - base64, (deprecated, use type instead) true to generate base64.\n * - compression, \"STORE\" by default.\n * - type, \"base64\" by default. Values are : string, base64, uint8array, arraybuffer, blob.\n * @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file\n */\n generate: function generate(options) {\n options = utils.extend(options || {}, {\n base64: true,\n compression: \"STORE\",\n compressionOptions: null,\n type: \"base64\",\n platform: \"DOS\",\n comment: null,\n mimeType: \"application/zip\",\n encodeFileName: utf8.utf8encode\n });\n utils.checkSupport(options.type);\n\n // accept nodejs `process.platform`\n if (options.platform === \"darwin\" || options.platform === \"freebsd\" || options.platform === \"linux\" || options.platform === \"sunos\") {\n options.platform = \"UNIX\";\n }\n if (options.platform === \"win32\") {\n options.platform = \"DOS\";\n }\n var zipData = [],\n encodedComment = utils.transformTo(\"string\", options.encodeFileName(options.comment || this.comment || \"\"));\n var localDirLength = 0,\n centralDirLength = 0,\n writer,\n i;\n\n // first, generate all the zip parts.\n for (var name in this.files) {\n if (!this.files.hasOwnProperty(name)) {\n continue;\n }\n var file = this.files[name];\n var compressionName = file.options.compression || options.compression.toUpperCase();\n var compression = compressions[compressionName];\n if (!compression) {\n throw new Error(compressionName + \" is not a valid compression method !\");\n }\n var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};\n var compressedObject = generateCompressedObjectFrom.call(this, file, compression, compressionOptions);\n var zipPart = generateZipParts.call(this, name, file, compressedObject, localDirLength, options.platform, options.encodeFileName);\n localDirLength += zipPart.fileRecord.length + compressedObject.compressedSize;\n centralDirLength += zipPart.dirRecord.length;\n zipData.push(zipPart);\n }\n var dirEnd = \"\";\n\n // end of central dir signature\n dirEnd = signature.CENTRAL_DIRECTORY_END +\n // number of this disk\n \"\\x00\\x00\" +\n // number of the disk with the start of the central directory\n \"\\x00\\x00\" +\n // total number of entries in the central directory on this disk\n decToHex(zipData.length, 2) +\n // total number of entries in the central directory\n decToHex(zipData.length, 2) +\n // size of the central directory 4 bytes\n decToHex(centralDirLength, 4) +\n // offset of start of central directory with respect to the starting disk number\n decToHex(localDirLength, 4) +\n // .ZIP file comment length\n decToHex(encodedComment.length, 2) +\n // .ZIP file comment\n encodedComment;\n\n // we have all the parts (and the total length)\n // time to create a writer !\n var typeName = options.type.toLowerCase();\n if (typeName === \"uint8array\" || typeName === \"arraybuffer\" || typeName === \"blob\" || typeName === \"nodebuffer\") {\n writer = new Uint8ArrayWriter(localDirLength + centralDirLength + dirEnd.length);\n } else {\n writer = new StringWriter(localDirLength + centralDirLength + dirEnd.length);\n }\n for (i = 0; i < zipData.length; i++) {\n writer.append(zipData[i].fileRecord);\n writer.append(zipData[i].compressedObject.compressedContent);\n }\n for (i = 0; i < zipData.length; i++) {\n writer.append(zipData[i].dirRecord);\n }\n writer.append(dirEnd);\n var zip = writer.finalize();\n switch (options.type.toLowerCase()) {\n // case \"zip is an Uint8Array\"\n case \"uint8array\":\n case \"arraybuffer\":\n case \"nodebuffer\":\n return utils.transformTo(options.type.toLowerCase(), zip);\n case \"blob\":\n return utils.arrayBuffer2Blob(utils.transformTo(\"arraybuffer\", zip), options.mimeType);\n // case \"zip is a string\"\n case \"base64\":\n return options.base64 ? base64.encode(zip) : zip;\n default:\n // case \"string\" :\n return zip;\n }\n },\n /**\n * @deprecated\n * This method will be removed in a future version without replacement.\n */\n crc32: function crc32(input, crc) {\n return _crc(input, crc);\n },\n /**\n * @deprecated\n * This method will be removed in a future version without replacement.\n */\n utf8encode: function utf8encode(string) {\n return utils.transformTo(\"string\", utf8.utf8encode(string));\n },\n /**\n * @deprecated\n * This method will be removed in a future version without replacement.\n */\n utf8decode: function utf8decode(input) {\n return utf8.utf8decode(input);\n }\n};\n/**\n * Transform this._data into a string.\n * @param {function} filter a function String -> String, applied if not null on the result.\n * @return {String} the string representing this._data.\n */\nfunction dataToString(asUTF8) {\n var result = getRawData(this);\n if (result === null || typeof result === \"undefined\") {\n return \"\";\n }\n // if the data is a base64 string, we decode it before checking the encoding !\n if (this.options.base64) {\n result = base64.decode(result);\n }\n if (asUTF8 && this.options.binary) {\n // PizZip.prototype.utf8decode supports arrays as input\n // skip to array => string step, utf8decode will do it.\n result = out.utf8decode(result);\n } else {\n // no utf8 transformation, do the array => string step.\n result = utils.transformTo(\"string\", result);\n }\n if (!asUTF8 && !this.options.binary) {\n result = utils.transformTo(\"string\", out.utf8encode(result));\n }\n return result;\n}\n/**\n * A simple object representing a file in the zip file.\n * @constructor\n * @param {string} name the name of the file\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data\n * @param {Object} options the options of the file\n */\nfunction ZipObject(name, data, options) {\n this.name = name;\n this.dir = options.dir;\n this.date = options.date;\n this.comment = options.comment;\n this.unixPermissions = options.unixPermissions;\n this.dosPermissions = options.dosPermissions;\n this._data = data;\n this.options = options;\n\n /*\n * This object contains initial values for dir and date.\n * With them, we can check if the user changed the deprecated metadata in\n * `ZipObject#options` or not.\n */\n this._initialMetadata = {\n dir: options.dir,\n date: options.date\n };\n}\nZipObject.prototype = {\n /**\n * Return the content as UTF8 string.\n * @return {string} the UTF8 string.\n */\n asText: function asText() {\n return dataToString.call(this, true);\n },\n /**\n * Returns the binary content.\n * @return {string} the content as binary.\n */\n asBinary: function asBinary() {\n return dataToString.call(this, false);\n },\n /**\n * Returns the content as a nodejs Buffer.\n * @return {Buffer} the content as a Buffer.\n */\n asNodeBuffer: function asNodeBuffer() {\n var result = getBinaryData(this);\n return utils.transformTo(\"nodebuffer\", result);\n },\n /**\n * Returns the content as an Uint8Array.\n * @return {Uint8Array} the content as an Uint8Array.\n */\n asUint8Array: function asUint8Array() {\n var result = getBinaryData(this);\n return utils.transformTo(\"uint8array\", result);\n },\n /**\n * Returns the content as an ArrayBuffer.\n * @return {ArrayBuffer} the content as an ArrayBufer.\n */\n asArrayBuffer: function asArrayBuffer() {\n return this.asUint8Array().buffer;\n }\n};\n\n/**\n * Transform an integer into a string in hexadecimal.\n * @private\n * @param {number} dec the number to convert.\n * @param {number} bytes the number of bytes to generate.\n * @returns {string} the result.\n */\nfunction decToHex(dec, bytes) {\n var hex = \"\",\n i;\n for (i = 0; i < bytes; i++) {\n hex += String.fromCharCode(dec & 0xff);\n dec >>>= 8;\n }\n return hex;\n}\n\n/**\n * Transforms the (incomplete) options from the user into the complete\n * set of options to create a file.\n * @private\n * @param {Object} o the options from the user.\n * @return {Object} the complete set of options.\n */\nfunction prepareFileAttrs(o) {\n o = o || {};\n if (o.base64 === true && (o.binary === null || o.binary === undefined)) {\n o.binary = true;\n }\n o = utils.extend(o, defaults);\n o.date = o.date || new Date();\n if (o.compression !== null) {\n o.compression = o.compression.toUpperCase();\n }\n return o;\n}\n\n/**\n * Add a file in the current folder.\n * @private\n * @param {string} name the name of the file\n * @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file\n * @param {Object} o the options of the file\n * @return {Object} the new file.\n */\nfunction fileAdd(name, data, o) {\n // be sure sub folders exist\n var dataType = utils.getTypeOf(data),\n parent;\n o = prepareFileAttrs(o);\n if (typeof o.unixPermissions === \"string\") {\n o.unixPermissions = parseInt(o.unixPermissions, 8);\n }\n\n // UNX_IFDIR 0040000 see zipinfo.c\n if (o.unixPermissions && o.unixPermissions & 0x4000) {\n o.dir = true;\n }\n // Bit 4 Directory\n if (o.dosPermissions && o.dosPermissions & 0x0010) {\n o.dir = true;\n }\n if (o.dir) {\n name = forceTrailingSlash(name);\n }\n if (o.createFolders && (parent = parentFolder(name))) {\n folderAdd.call(this, parent, true);\n }\n if (o.dir || data === null || typeof data === \"undefined\") {\n o.base64 = false;\n o.binary = false;\n data = null;\n dataType = null;\n } else if (dataType === \"string\") {\n if (o.binary && !o.base64) {\n // optimizedBinaryString == true means that the file has already been filtered with a 0xFF mask\n if (o.optimizedBinaryString !== true) {\n // this is a string, not in a base64 format.\n // Be sure that this is a correct \"binary string\"\n data = utils.string2binary(data);\n }\n }\n } else {\n // arraybuffer, uint8array, ...\n o.base64 = false;\n o.binary = true;\n if (!dataType && !(data instanceof CompressedObject)) {\n throw new Error(\"The data of '\" + name + \"' is in an unsupported format !\");\n }\n\n // special case : it's way easier to work with Uint8Array than with ArrayBuffer\n if (dataType === \"arraybuffer\") {\n data = utils.transformTo(\"uint8array\", data);\n }\n }\n var object = new ZipObject(name, data, o);\n this.files[name] = object;\n return object;\n}\n\n/**\n * Find the parent folder of the path.\n * @private\n * @param {string} path the path to use\n * @return {string} the parent folder, or \"\"\n */\nfunction parentFolder(path) {\n if (path.slice(-1) === \"/\") {\n path = path.substring(0, path.length - 1);\n }\n var lastSlash = path.lastIndexOf(\"/\");\n return lastSlash > 0 ? path.substring(0, lastSlash) : \"\";\n}\n\n/**\n * Returns the path with a slash at the end.\n * @private\n * @param {String} path the path to check.\n * @return {String} the path with a trailing slash.\n */\nfunction forceTrailingSlash(path) {\n // Check the name ends with a /\n if (path.slice(-1) !== \"/\") {\n path += \"/\"; // IE doesn't like substr(-1)\n }\n return path;\n}\n/**\n * Add a (sub) folder in the current folder.\n * @private\n * @param {string} name the folder's name\n * @param {boolean=} [createFolders] If true, automatically create sub\n * folders. Defaults to false.\n * @return {Object} the new folder.\n */\nfunction folderAdd(name, createFolders) {\n createFolders = typeof createFolders !== \"undefined\" ? createFolders : false;\n name = forceTrailingSlash(name);\n\n // Does this folder already exist?\n if (!this.files[name]) {\n fileAdd.call(this, name, null, {\n dir: true,\n createFolders: createFolders\n });\n }\n return this.files[name];\n}\n\n/**\n * Generate a PizZip.CompressedObject for a given zipOject.\n * @param {ZipObject} file the object to read.\n * @param {PizZip.compression} compression the compression to use.\n * @param {Object} compressionOptions the options to use when compressing.\n * @return {PizZip.CompressedObject} the compressed result.\n */\nfunction generateCompressedObjectFrom(file, compression, compressionOptions) {\n var result = new CompressedObject();\n var content;\n\n // the data has not been decompressed, we might reuse things !\n if (file._data instanceof CompressedObject) {\n result.uncompressedSize = file._data.uncompressedSize;\n result.crc32 = file._data.crc32;\n if (result.uncompressedSize === 0 || file.dir) {\n compression = compressions.STORE;\n result.compressedContent = \"\";\n result.crc32 = 0;\n } else if (file._data.compressionMethod === compression.magic) {\n result.compressedContent = file._data.getCompressedContent();\n } else {\n content = file._data.getContent();\n // need to decompress / recompress\n result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content), compressionOptions);\n }\n } else {\n // have uncompressed data\n content = getBinaryData(file);\n if (!content || content.length === 0 || file.dir) {\n compression = compressions.STORE;\n content = \"\";\n }\n result.uncompressedSize = content.length;\n result.crc32 = _crc(content);\n result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content), compressionOptions);\n }\n result.compressedSize = result.compressedContent.length;\n result.compressionMethod = compression.magic;\n return result;\n}\n\n/**\n * Generate the UNIX part of the external file attributes.\n * @param {Object} unixPermissions the unix permissions or null.\n * @param {Boolean} isDir true if the entry is a directory, false otherwise.\n * @return {Number} a 32 bit integer.\n *\n * adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :\n *\n * TTTTsstrwxrwxrwx0000000000ADVSHR\n * ^^^^____________________________ file type, see zipinfo.c (UNX_*)\n * ^^^_________________________ setuid, setgid, sticky\n * ^^^^^^^^^________________ permissions\n * ^^^^^^^^^^______ not used ?\n * ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only\n */\nfunction generateUnixExternalFileAttr(unixPermissions, isDir) {\n var result = unixPermissions;\n if (!unixPermissions) {\n // I can't use octal values in strict mode, hence the hexa.\n // 040775 => 0x41fd\n // 0100664 => 0x81b4\n result = isDir ? 0x41fd : 0x81b4;\n }\n return (result & 0xffff) << 16;\n}\n\n/**\n * Generate the DOS part of the external file attributes.\n * @param {Object} dosPermissions the dos permissions or null.\n * @param {Boolean} isDir true if the entry is a directory, false otherwise.\n * @return {Number} a 32 bit integer.\n *\n * Bit 0 Read-Only\n * Bit 1 Hidden\n * Bit 2 System\n * Bit 3 Volume Label\n * Bit 4 Directory\n * Bit 5 Archive\n */\nfunction generateDosExternalFileAttr(dosPermissions) {\n // the dir flag is already set for compatibility\n\n return (dosPermissions || 0) & 0x3f;\n}\n\n/**\n * Generate the various parts used in the construction of the final zip file.\n * @param {string} name the file name.\n * @param {ZipObject} file the file content.\n * @param {PizZip.CompressedObject} compressedObject the compressed object.\n * @param {number} offset the current offset from the start of the zip file.\n * @param {String} platform let's pretend we are this platform (change platform dependents fields)\n * @param {Function} encodeFileName the function to encode the file name / comment.\n * @return {object} the zip parts.\n */\nfunction generateZipParts(name, file, compressedObject, offset, platform, encodeFileName) {\n var useCustomEncoding = encodeFileName !== utf8.utf8encode,\n encodedFileName = utils.transformTo(\"string\", encodeFileName(file.name)),\n utfEncodedFileName = utils.transformTo(\"string\", utf8.utf8encode(file.name)),\n comment = file.comment || \"\",\n encodedComment = utils.transformTo(\"string\", encodeFileName(comment)),\n utfEncodedComment = utils.transformTo(\"string\", utf8.utf8encode(comment)),\n useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,\n useUTF8ForComment = utfEncodedComment.length !== comment.length,\n o = file.options;\n var dosTime,\n dosDate,\n extraFields = \"\",\n unicodePathExtraField = \"\",\n unicodeCommentExtraField = \"\",\n dir,\n date;\n\n // handle the deprecated options.dir\n if (file._initialMetadata.dir !== file.dir) {\n dir = file.dir;\n } else {\n dir = o.dir;\n }\n\n // handle the deprecated options.date\n if (file._initialMetadata.date !== file.date) {\n date = file.date;\n } else {\n date = o.date;\n }\n var extFileAttr = 0;\n var versionMadeBy = 0;\n if (dir) {\n // dos or unix, we set the dos dir flag\n extFileAttr |= 0x00010;\n }\n if (platform === \"UNIX\") {\n versionMadeBy = 0x031e; // UNIX, version 3.0\n extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);\n } else {\n // DOS or other, fallback to DOS\n versionMadeBy = 0x0014; // DOS, version 2.0\n extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);\n }\n\n // date\n // @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html\n // @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html\n // @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html\n\n dosTime = date.getHours();\n dosTime <<= 6;\n dosTime |= date.getMinutes();\n dosTime <<= 5;\n dosTime |= date.getSeconds() / 2;\n dosDate = date.getFullYear() - 1980;\n dosDate <<= 4;\n dosDate |= date.getMonth() + 1;\n dosDate <<= 5;\n dosDate |= date.getDate();\n if (useUTF8ForFileName) {\n // set the unicode path extra field. unzip needs at least one extra\n // field to correctly handle unicode path, so using the path is as good\n // as any other information. This could improve the situation with\n // other archive managers too.\n // This field is usually used without the utf8 flag, with a non\n // unicode path in the header (winrar, winzip). This helps (a bit)\n // with the messy Windows' default compressed folders feature but\n // breaks on p7zip which doesn't seek the unicode path extra field.\n // So for now, UTF-8 everywhere !\n unicodePathExtraField =\n // Version\n decToHex(1, 1) +\n // NameCRC32\n decToHex(_crc(encodedFileName), 4) +\n // UnicodeName\n utfEncodedFileName;\n extraFields +=\n // Info-ZIP Unicode Path