UNPKG

unzipper-esm

Version:
35 lines (33 loc) 1.71 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = parseExtraField; var _parseBuffer = _interopRequireDefault(require("./parseBuffer.js")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } function parseExtraField(extraField, vars) { var extra; // Find the ZIP64 header, if present. while (!extra && extraField && extraField.length) { var candidateExtra = (0, _parseBuffer["default"])(extraField, [['signature', 2], ['partSize', 2]]); if (candidateExtra.signature === 0x0001) { // parse buffer based on data in ZIP64 central directory; order is important! var fieldsToExpect = []; if (vars.uncompressedSize === 0xffffffff) fieldsToExpect.push(['uncompressedSize', 8]); if (vars.compressedSize === 0xffffffff) fieldsToExpect.push(['compressedSize', 8]); if (vars.offsetToLocalFileHeader === 0xffffffff) fieldsToExpect.push(['offsetToLocalFileHeader', 8]); // slice off the 4 bytes for signature and partSize extra = (0, _parseBuffer["default"])(extraField.slice(4), fieldsToExpect); } else { // Advance the buffer to the next part. // The total size of this part is the 4 byte header + partsize. extraField = extraField.slice(candidateExtra.partSize + 4); } } extra = extra || {}; if (vars.compressedSize === 0xffffffff) vars.compressedSize = extra.compressedSize; if (vars.uncompressedSize === 0xffffffff) vars.uncompressedSize = extra.uncompressedSize; if (vars.offsetToLocalFileHeader === 0xffffffff) vars.offsetToLocalFileHeader = extra.offsetToLocalFileHeader; return extra; } //# sourceMappingURL=parseExtraField.js.map