UNPKG

zip-iterator

Version:

Extract contents from zip archive type using an iterator API using streams or paths. Use stream interface and pipe transforms to add decompression algorithms

1 lines 2.75 kB
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/iterators/zip-iterator/src/lib/parseExternalFileAttributes.mjs"],"sourcesContent":["// From: https://github.com/bower/decompress-zip/blob/master/lib/structures.js\n\nexport default function parseExternalFileAttributes(externalAttributes, platform) {\n const types = {\n // In theory, any of these could be set. Realistically, though, it will\n // be regular, directory or symlink\n 1: 'namedpipe',\n 2: 'character',\n 4: 'directory',\n 6: 'block',\n 8: 'file',\n 10: 'symlink',\n 12: 'socket',\n };\n\n switch (platform) {\n case 3: // Unix\n return {\n platform: 'Unix',\n type: types[(externalAttributes >> 28) & 0x0f],\n mode: (externalAttributes >> 16) & 0xfff,\n };\n\n // case 0: // MSDOS\n default: {\n if (platform !== 0) {\n console.warn(`Possibly unsupported ZIP platform type, ${platform}`);\n }\n\n const attribs = {\n A: (externalAttributes >> 5) & 0x01,\n D: (externalAttributes >> 4) & 0x01,\n V: (externalAttributes >> 3) & 0x01,\n S: (externalAttributes >> 2) & 0x01,\n H: (externalAttributes >> 1) & 0x01,\n R: externalAttributes & 0x01,\n };\n\n // With no better guidance we'll make the default permissions ugo+r\n let mode = 0o0444;\n\n if (attribs.D) {\n mode |= 0o0111; // Set the execute bit\n }\n\n if (!attribs.R) {\n mode |= 0o0222; // Set the write bit\n }\n\n mode &= ~process.umask();\n\n return {\n platform: 'DOS',\n type: attribs.D ? 'directory' : 'file',\n mode: mode,\n };\n }\n }\n}\n"],"names":["parseExternalFileAttributes","externalAttributes","platform","types","type","mode","console","warn","attribs","A","D","V","S","H","R","process","umask"],"mappings":"AAAA,8EAA8E;AAE9E,eAAe,SAASA,4BAA4BC,kBAAkB,EAAEC,QAAQ;IAC9E,MAAMC,QAAQ;QACZ,uEAAuE;QACvE,mCAAmC;QACnC,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,GAAG;QACH,IAAI;QACJ,IAAI;IACN;IAEA,OAAQD;QACN,KAAK;YACH,OAAO;gBACLA,UAAU;gBACVE,MAAMD,KAAK,CAAC,AAACF,sBAAsB,KAAM,KAAK;gBAC9CI,MAAM,AAACJ,sBAAsB,KAAM;YACrC;QAEF,mBAAmB;QACnB;YAAS;gBACP,IAAIC,aAAa,GAAG;oBAClBI,QAAQC,IAAI,CAAC,CAAC,wCAAwC,EAAEL,UAAU;gBACpE;gBAEA,MAAMM,UAAU;oBACdC,GAAG,AAACR,sBAAsB,IAAK;oBAC/BS,GAAG,AAACT,sBAAsB,IAAK;oBAC/BU,GAAG,AAACV,sBAAsB,IAAK;oBAC/BW,GAAG,AAACX,sBAAsB,IAAK;oBAC/BY,GAAG,AAACZ,sBAAsB,IAAK;oBAC/Ba,GAAGb,qBAAqB;gBAC1B;gBAEA,mEAAmE;gBACnE,IAAII,OAAO;gBAEX,IAAIG,QAAQE,CAAC,EAAE;oBACbL,QAAQ,QAAQ,sBAAsB;gBACxC;gBAEA,IAAI,CAACG,QAAQM,CAAC,EAAE;oBACdT,QAAQ,QAAQ,oBAAoB;gBACtC;gBAEAA,QAAQ,CAACU,QAAQC,KAAK;gBAEtB,OAAO;oBACLd,UAAU;oBACVE,MAAMI,QAAQE,CAAC,GAAG,cAAc;oBAChCL,MAAMA;gBACR;YACF;IACF;AACF"}