1 | export const Constants: {
|
2 | /* The local file header */
|
3 | LOCHDR: 30; // LOC header size
|
4 | LOCSIG: 0x04034b50; // "PK\003\004"
|
5 | LOCVER: 4; // version needed to extract
|
6 | LOCFLG: 6; // general purpose bit flag
|
7 | LOCHOW: 8; // compression method
|
8 | LOCTIM: 10; // modification time (2 bytes time, 2 bytes date)
|
9 | LOCCRC: 14; // uncompressed file crc-32 value
|
10 | LOCSIZ: 18; // compressed size
|
11 | LOCLEN: 22; // uncompressed size
|
12 | LOCNAM: 26; // filename length
|
13 | LOCEXT: 28; // extra field length
|
14 |
|
15 | /* The Data descriptor */
|
16 | EXTSIG: 0x08074b50; // "PK\007\008"
|
17 | EXTHDR: 16; // EXT header size
|
18 | EXTCRC: 4; // uncompressed file crc-32 value
|
19 | EXTSIZ: 8; // compressed size
|
20 | EXTLEN: 12; // uncompressed size
|
21 |
|
22 | /* The central directory file header */
|
23 | CENHDR: 46; // CEN header size
|
24 | CENSIG: 0x02014b50; // "PK\001\002"
|
25 | CENVEM: 4; // version made by
|
26 | CENVER: 6; // version needed to extract
|
27 | CENFLG: 8; // encrypt, decrypt flags
|
28 | CENHOW: 10; // compression method
|
29 | CENTIM: 12; // modification time (2 bytes time, 2 bytes date)
|
30 | CENCRC: 16; // uncompressed file crc-32 value
|
31 | CENSIZ: 20; // compressed size
|
32 | CENLEN: 24; // uncompressed size
|
33 | CENNAM: 28; // filename length
|
34 | CENEXT: 30; // extra field length
|
35 | CENCOM: 32; // file comment length
|
36 | CENDSK: 34; // volume number start
|
37 | CENATT: 36; // internal file attributes
|
38 | CENATX: 38; // external file attributes (host system dependent)
|
39 | CENOFF: 42; // LOC header offset
|
40 |
|
41 | /* The entries in the end of central directory */
|
42 | ENDHDR: 22; // END header size
|
43 | ENDSIG: 0x06054b50; // "PK\005\006"
|
44 | ENDSUB: 8; // number of entries on this disk
|
45 | ENDTOT: 10; // total number of entries
|
46 | ENDSIZ: 12; // central directory size in bytes
|
47 | ENDOFF: 16; // offset of first CEN header
|
48 | ENDCOM: 20; // zip file comment length
|
49 |
|
50 | END64HDR: 20; // zip64 END header size
|
51 | END64SIG: 0x07064b50; // zip64 Locator signature, "PK\006\007"
|
52 | END64START: 4; // number of the disk with the start of the zip64
|
53 | END64OFF: 8; // relative offset of the zip64 end of central directory
|
54 | END64NUMDISKS: 16; // total number of disks
|
55 |
|
56 | ZIP64SIG: 0x06064b50; // zip64 signature, "PK\006\006"
|
57 | ZIP64HDR: 56; // zip64 record minimum size
|
58 | ZIP64LEAD: 12; // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
|
59 | ZIP64SIZE: 4; // zip64 size of the central directory record
|
60 | ZIP64VEM: 12; // zip64 version made by
|
61 | ZIP64VER: 14; // zip64 version needed to extract
|
62 | ZIP64DSK: 16; // zip64 number of this disk
|
63 | ZIP64DSKDIR: 20; // number of the disk with the start of the record directory
|
64 | ZIP64SUB: 24; // number of entries on this disk
|
65 | ZIP64TOT: 32; // total number of entries
|
66 | ZIP64SIZB: 40; // zip64 central directory size in bytes
|
67 | ZIP64OFF: 48; // offset of start of central directory with respect to the starting disk number
|
68 | ZIP64EXTRA: 56; // extensible data sector
|
69 |
|
70 | /* Compression methods */
|
71 | STORED: 0; // no compression
|
72 | SHRUNK: 1; // shrunk
|
73 | REDUCED1: 2; // reduced with compression factor 1
|
74 | REDUCED2: 3; // reduced with compression factor 2
|
75 | REDUCED3: 4; // reduced with compression factor 3
|
76 | REDUCED4: 5; // reduced with compression factor 4
|
77 | IMPLODED: 6; // imploded
|
78 | // 7 reserved for Tokenizing compression algorithm
|
79 | DEFLATED: 8; // deflated
|
80 | ENHANCED_DEFLATED: 9; // enhanced deflated
|
81 | PKWARE: 10; // PKWare DCL imploded
|
82 | // 11 reserved by PKWARE
|
83 | BZIP2: 12; // compressed using BZIP2
|
84 | // 13 reserved by PKWARE
|
85 | LZMA: 14; // LZMA
|
86 | // 15-17 reserved by PKWARE
|
87 | IBM_TERSE: 18; // compressed using IBM TERSE
|
88 | IBM_LZ77: 19; // IBM LZ77 z
|
89 | AES_ENCRYPT: 99; // WinZIP AES encryption method
|
90 |
|
91 | /* General purpose bit flag */
|
92 | // values can obtained with expression 2**bitnr
|
93 | FLG_ENC: 1; // Bit 0: encrypted file
|
94 | FLG_COMP1: 2; // Bit 1, compression option
|
95 | FLG_COMP2: 4; // Bit 2, compression option
|
96 | FLG_DESC: 8; // Bit 3, data descriptor
|
97 | FLG_ENH: 16; // Bit 4, enhanced deflating
|
98 | FLG_PATCH: 32; // Bit 5, indicates that the file is compressed patched data.
|
99 | FLG_STR: 64; // Bit 6, strong encryption (patented)
|
100 | // Bits 7-10: Currently unused.
|
101 | FLG_EFS: 2048; // Bit 11: Language encoding flag (EFS)
|
102 | // Bit 12: Reserved by PKWARE for enhanced compression.
|
103 | // Bit 13: encrypted the Central Directory (patented).
|
104 | // Bits 14-15: Reserved by PKWARE.
|
105 | FLG_MSK: 4096; // mask header values
|
106 |
|
107 | /* Load type */
|
108 | FILE: 2;
|
109 | BUFFER: 1;
|
110 | NONE: 0;
|
111 |
|
112 | /* 4.5 Extensible data fields */
|
113 | EF_ID: 0;
|
114 | EF_SIZE: 2;
|
115 |
|
116 | /* Header IDs */
|
117 | ID_ZIP64: 0x0001;
|
118 | ID_AVINFO: 0x0007;
|
119 | ID_PFS: 0x0008;
|
120 | ID_OS2: 0x0009;
|
121 | ID_NTFS: 0x000a;
|
122 | ID_OPENVMS: 0x000c;
|
123 | ID_UNIX: 0x000d;
|
124 | ID_FORK: 0x000e;
|
125 | ID_PATCH: 0x000f;
|
126 | ID_X509_PKCS7: 0x0014;
|
127 | ID_X509_CERTID_F: 0x0015;
|
128 | ID_X509_CERTID_C: 0x0016;
|
129 | ID_STRONGENC: 0x0017;
|
130 | ID_RECORD_MGT: 0x0018;
|
131 | ID_X509_PKCS7_RL: 0x0019;
|
132 | ID_IBM1: 0x0065;
|
133 | ID_IBM2: 0x0066;
|
134 | ID_POSZIP: 0x4690;
|
135 |
|
136 | EF_ZIP64_OR_32: 0xffffffff;
|
137 | EF_ZIP64_OR_16: 0xffff;
|
138 | EF_ZIP64_SUNCOMP: 0;
|
139 | EF_ZIP64_SCOMP: 8;
|
140 | EF_ZIP64_RHO: 16;
|
141 | EF_ZIP64_DSN: 24;
|
142 | };
|
143 |
|
144 | export const Errors: {
|
145 | /* Header error messages */
|
146 | INVALID_LOC: "Invalid LOC header (bad signature)";
|
147 | INVALID_CEN: "Invalid CEN header (bad signature)";
|
148 | INVALID_END: "Invalid END header (bad signature)";
|
149 |
|
150 | /* ZipEntry error messages */
|
151 | NO_DATA: "Nothing to decompress";
|
152 | BAD_CRC: "CRC32 checksum failed";
|
153 | FILE_IN_THE_WAY: "There is a file in the way: %s";
|
154 | UNKNOWN_METHOD: "Invalid/unsupported compression method";
|
155 |
|
156 | /* Inflater error messages */
|
157 | AVAIL_DATA: "inflate::Available inflate data did not terminate";
|
158 | INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block";
|
159 | TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes";
|
160 | INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths";
|
161 | INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length";
|
162 | INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete";
|
163 | INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths";
|
164 | INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths";
|
165 | INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement";
|
166 | INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)";
|
167 |
|
168 | /* ADM-ZIP error messages */
|
169 | CANT_EXTRACT_FILE: "Could not extract the file";
|
170 | CANT_OVERRIDE: "Target file already exists";
|
171 | NO_ZIP: "No zip file was loaded";
|
172 | NO_ENTRY: "Entry doesn't exist";
|
173 | DIRECTORY_CONTENT_ERROR: "A directory cannot have content";
|
174 | FILE_NOT_FOUND: "File not found: %s";
|
175 | NOT_IMPLEMENTED: "Not implemented";
|
176 | INVALID_FILENAME: "Invalid filename";
|
177 | INVALID_FORMAT: "Invalid or unsupported zip format. No END header found";
|
178 | };
|