author | mbaesken |
Fri, 12 Apr 2019 09:13:50 +0200 | |
changeset 54572 | 75a42622414e |
parent 53043 | fd2e8f941ded |
child 57665 | bf325b739c8a |
permissions | -rw-r--r-- |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
1 |
/* |
53043
fd2e8f941ded
8215472: (zipfs) Cleanups in implementation classes of jdk.zipfs and tests
clanger
parents:
50238
diff
changeset
|
2 |
* Copyright (c) 2009, 2018, Oracle and/or its affiliates. All rights reserved. |
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
4 |
* |
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
10 |
* |
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
15 |
* accompanied this code). |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
16 |
* |
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
20 |
* |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
23 |
* questions. |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
24 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
25 |
|
23925
0d5f2d863262
8038500: (zipfs) Upgrade ZIP provider to be a supported provider
sherman
parents:
14342
diff
changeset
|
26 |
package jdk.nio.zipfs; |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
27 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
28 |
/** |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
29 |
* @author Xueming Shen |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
30 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
31 |
class ZipConstants { |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
32 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
33 |
* Compression methods |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
34 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
35 |
static final int METHOD_STORED = 0; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
36 |
static final int METHOD_DEFLATED = 8; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
37 |
static final int METHOD_DEFLATED64 = 9; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
38 |
static final int METHOD_BZIP2 = 12; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
39 |
static final int METHOD_LZMA = 14; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
40 |
static final int METHOD_LZ77 = 19; |
7189 | 41 |
static final int METHOD_AES = 99; |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
42 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
43 |
/* |
50238
a9307f400f5a
8203328: Rename EFS in java.util.zip internals to something meaningful
martin
parents:
47216
diff
changeset
|
44 |
* General purpose bit flag |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
45 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
46 |
static final int FLAG_ENCRYPTED = 0x01; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
47 |
static final int FLAG_DATADESCR = 0x08; // crc, size and csize in dd |
50238
a9307f400f5a
8203328: Rename EFS in java.util.zip internals to something meaningful
martin
parents:
47216
diff
changeset
|
48 |
static final int FLAG_USE_UTF8 = 0x800; // If this bit is set the filename and |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
49 |
// comment fields for this file must be |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
50 |
// encoded using UTF-8. |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
51 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
52 |
* Header signatures |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
53 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
54 |
static long LOCSIG = 0x04034b50L; // "PK\003\004" |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
55 |
static long EXTSIG = 0x08074b50L; // "PK\007\008" |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
56 |
static long CENSIG = 0x02014b50L; // "PK\001\002" |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
57 |
static long ENDSIG = 0x06054b50L; // "PK\005\006" |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
58 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
59 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
60 |
* Header sizes in bytes (including signatures) |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
61 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
62 |
static final int LOCHDR = 30; // LOC header size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
63 |
static final int EXTHDR = 16; // EXT header size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
64 |
static final int CENHDR = 46; // CEN header size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
65 |
static final int ENDHDR = 22; // END header size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
66 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
67 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
68 |
* Local file (LOC) header field offsets |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
69 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
70 |
static final int LOCVER = 4; // version needed to extract |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
71 |
static final int LOCFLG = 6; // general purpose bit flag |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
72 |
static final int LOCHOW = 8; // compression method |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
73 |
static final int LOCTIM = 10; // modification time |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
74 |
static final int LOCCRC = 14; // uncompressed file crc-32 value |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
75 |
static final int LOCSIZ = 18; // compressed size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
76 |
static final int LOCLEN = 22; // uncompressed size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
77 |
static final int LOCNAM = 26; // filename length |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
78 |
static final int LOCEXT = 28; // extra field length |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
79 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
80 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
81 |
* Extra local (EXT) header field offsets |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
82 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
83 |
static final int EXTCRC = 4; // uncompressed file crc-32 value |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
84 |
static final int EXTSIZ = 8; // compressed size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
85 |
static final int EXTLEN = 12; // uncompressed size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
86 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
87 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
88 |
* Central directory (CEN) header field offsets |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
89 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
90 |
static final int CENVEM = 4; // version made by |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
91 |
static final int CENVER = 6; // version needed to extract |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
92 |
static final int CENFLG = 8; // encrypt, decrypt flags |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
93 |
static final int CENHOW = 10; // compression method |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
94 |
static final int CENTIM = 12; // modification time |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
95 |
static final int CENCRC = 16; // uncompressed file crc-32 value |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
96 |
static final int CENSIZ = 20; // compressed size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
97 |
static final int CENLEN = 24; // uncompressed size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
98 |
static final int CENNAM = 28; // filename length |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
99 |
static final int CENEXT = 30; // extra field length |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
100 |
static final int CENCOM = 32; // comment length |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
101 |
static final int CENDSK = 34; // disk number start |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
102 |
static final int CENATT = 36; // internal file attributes |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
103 |
static final int CENATX = 38; // external file attributes |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
104 |
static final int CENOFF = 42; // LOC header offset |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
105 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
106 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
107 |
* End of central directory (END) header field offsets |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
108 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
109 |
static final int ENDSUB = 8; // number of entries on this disk |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
110 |
static final int ENDTOT = 10; // total number of entries |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
111 |
static final int ENDSIZ = 12; // central directory size in bytes |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
112 |
static final int ENDOFF = 16; // offset of first CEN header |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
113 |
static final int ENDCOM = 20; // zip file comment length |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
114 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
115 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
116 |
* ZIP64 constants |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
117 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
118 |
static final long ZIP64_ENDSIG = 0x06064b50L; // "PK\006\006" |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
119 |
static final long ZIP64_LOCSIG = 0x07064b50L; // "PK\006\007" |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
120 |
static final int ZIP64_ENDHDR = 56; // ZIP64 end header size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
121 |
static final int ZIP64_LOCHDR = 20; // ZIP64 end loc header size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
122 |
static final int ZIP64_EXTHDR = 24; // EXT header size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
123 |
static final int ZIP64_EXTID = 0x0001; // Extra field Zip64 header ID |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
124 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
125 |
static final int ZIP64_MINVAL32 = 0xFFFF; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
126 |
static final long ZIP64_MINVAL = 0xFFFFFFFFL; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
127 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
128 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
129 |
* Zip64 End of central directory (END) header field offsets |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
130 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
131 |
static final int ZIP64_ENDLEN = 4; // size of zip64 end of central dir |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
132 |
static final int ZIP64_ENDVEM = 12; // version made by |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
133 |
static final int ZIP64_ENDVER = 14; // version needed to extract |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
134 |
static final int ZIP64_ENDNMD = 16; // number of this disk |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
135 |
static final int ZIP64_ENDDSK = 20; // disk number of start |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
136 |
static final int ZIP64_ENDTOD = 24; // total number of entries on this disk |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
137 |
static final int ZIP64_ENDTOT = 32; // total number of entries |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
138 |
static final int ZIP64_ENDSIZ = 40; // central directory size in bytes |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
139 |
static final int ZIP64_ENDOFF = 48; // offset of first CEN header |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
140 |
static final int ZIP64_ENDEXT = 56; // zip64 extensible data sector |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
141 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
142 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
143 |
* Zip64 End of central directory locator field offsets |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
144 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
145 |
static final int ZIP64_LOCDSK = 4; // disk number start |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
146 |
static final int ZIP64_LOCOFF = 8; // offset of zip64 end |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
147 |
static final int ZIP64_LOCTOT = 16; // total number of disks |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
148 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
149 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
150 |
* Zip64 Extra local (EXT) header field offsets |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
151 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
152 |
static final int ZIP64_EXTCRC = 4; // uncompressed file crc-32 value |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
153 |
static final int ZIP64_EXTSIZ = 8; // compressed size, 8-byte |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
154 |
static final int ZIP64_EXTLEN = 16; // uncompressed size, 8-byte |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
155 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
156 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
157 |
* Extra field header ID |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
158 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
159 |
static final int EXTID_ZIP64 = 0x0001; // ZIP64 |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
160 |
static final int EXTID_NTFS = 0x000a; // NTFS |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
161 |
static final int EXTID_UNIX = 0x000d; // UNIX |
7189 | 162 |
static final int EXTID_EFS = 0x0017; // Strong Encryption |
163 |
static final int EXTID_EXTT = 0x5455; // Info-ZIP Extended Timestamp |
|
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
164 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
165 |
/* |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
166 |
* fields access methods |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
167 |
*/ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
168 |
/////////////////////////////////////////////////////// |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
169 |
static final int CH(byte[] b, int n) { |
11828
590711df7828
7143629: JDK jar/zip code should use unsigned library support
darcy
parents:
10292
diff
changeset
|
170 |
return Byte.toUnsignedInt(b[n]); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
171 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
172 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
173 |
static final int SH(byte[] b, int n) { |
11828
590711df7828
7143629: JDK jar/zip code should use unsigned library support
darcy
parents:
10292
diff
changeset
|
174 |
return Byte.toUnsignedInt(b[n]) | (Byte.toUnsignedInt(b[n + 1]) << 8); |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
175 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
176 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
177 |
static final long LG(byte[] b, int n) { |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
178 |
return ((SH(b, n)) | (SH(b, n + 2) << 16)) & 0xffffffffL; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
179 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
180 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
181 |
static final long LL(byte[] b, int n) { |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
182 |
return (LG(b, n)) | (LG(b, n + 4) << 32); |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
183 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
184 |
|
29714
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
185 |
static long getSig(byte[] b, int n) { return LG(b, n); } |
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
186 |
|
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
187 |
private static boolean pkSigAt(byte[] b, int n, int b1, int b2) { |
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
188 |
return b[n] == 'P' & b[n + 1] == 'K' & b[n + 2] == b1 & b[n + 3] == b2; |
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
189 |
} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
190 |
|
29714
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
191 |
static boolean cenSigAt(byte[] b, int n) { return pkSigAt(b, n, 1, 2); } |
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
192 |
static boolean locSigAt(byte[] b, int n) { return pkSigAt(b, n, 3, 4); } |
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
193 |
static boolean endSigAt(byte[] b, int n) { return pkSigAt(b, n, 5, 6); } |
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
194 |
static boolean extSigAt(byte[] b, int n) { return pkSigAt(b, n, 7, 8); } |
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
195 |
static boolean end64SigAt(byte[] b, int n) { return pkSigAt(b, n, 6, 6); } |
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
196 |
static boolean locator64SigAt(byte[] b, int n) { return pkSigAt(b, n, 6, 7); } |
afac043e9bf0
8075774: Small readability and performance improvements for zipfs
martin
parents:
25859
diff
changeset
|
197 |
|
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
198 |
// local file (LOC) header fields |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
199 |
static final long LOCSIG(byte[] b) { return LG(b, 0); } // signature |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
200 |
static final int LOCVER(byte[] b) { return SH(b, 4); } // version needed to extract |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
201 |
static final int LOCFLG(byte[] b) { return SH(b, 6); } // general purpose bit flags |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
202 |
static final int LOCHOW(byte[] b) { return SH(b, 8); } // compression method |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
203 |
static final long LOCTIM(byte[] b) { return LG(b, 10);} // modification time |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
204 |
static final long LOCCRC(byte[] b) { return LG(b, 14);} // crc of uncompressed data |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
205 |
static final long LOCSIZ(byte[] b) { return LG(b, 18);} // compressed data size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
206 |
static final long LOCLEN(byte[] b) { return LG(b, 22);} // uncompressed data size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
207 |
static final int LOCNAM(byte[] b) { return SH(b, 26);} // filename length |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
208 |
static final int LOCEXT(byte[] b) { return SH(b, 28);} // extra field length |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
209 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
210 |
// extra local (EXT) header fields |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
211 |
static final long EXTCRC(byte[] b) { return LG(b, 4);} // crc of uncompressed data |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
212 |
static final long EXTSIZ(byte[] b) { return LG(b, 8);} // compressed size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
213 |
static final long EXTLEN(byte[] b) { return LG(b, 12);} // uncompressed size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
214 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
215 |
// end of central directory header (END) fields |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
216 |
static final int ENDSUB(byte[] b) { return SH(b, 8); } // number of entries on this disk |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
217 |
static final int ENDTOT(byte[] b) { return SH(b, 10);} // total number of entries |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
218 |
static final long ENDSIZ(byte[] b) { return LG(b, 12);} // central directory size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
219 |
static final long ENDOFF(byte[] b) { return LG(b, 16);} // central directory offset |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
220 |
static final int ENDCOM(byte[] b) { return SH(b, 20);} // size of zip file comment |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
221 |
static final int ENDCOM(byte[] b, int off) { return SH(b, off + 20);} |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
222 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
223 |
// zip64 end of central directory recoder fields |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
224 |
static final long ZIP64_ENDTOD(byte[] b) { return LL(b, 24);} // total number of entries on disk |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
225 |
static final long ZIP64_ENDTOT(byte[] b) { return LL(b, 32);} // total number of entries |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
226 |
static final long ZIP64_ENDSIZ(byte[] b) { return LL(b, 40);} // central directory size |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
227 |
static final long ZIP64_ENDOFF(byte[] b) { return LL(b, 48);} // central directory offset |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
228 |
static final long ZIP64_LOCOFF(byte[] b) { return LL(b, 8);} // zip64 end offset |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
229 |
|
7189 | 230 |
// central directory header (CEN) fields |
231 |
static final long CENSIG(byte[] b, int pos) { return LG(b, pos + 0); } |
|
232 |
static final int CENVEM(byte[] b, int pos) { return SH(b, pos + 4); } |
|
233 |
static final int CENVER(byte[] b, int pos) { return SH(b, pos + 6); } |
|
234 |
static final int CENFLG(byte[] b, int pos) { return SH(b, pos + 8); } |
|
235 |
static final int CENHOW(byte[] b, int pos) { return SH(b, pos + 10);} |
|
236 |
static final long CENTIM(byte[] b, int pos) { return LG(b, pos + 12);} |
|
237 |
static final long CENCRC(byte[] b, int pos) { return LG(b, pos + 16);} |
|
238 |
static final long CENSIZ(byte[] b, int pos) { return LG(b, pos + 20);} |
|
239 |
static final long CENLEN(byte[] b, int pos) { return LG(b, pos + 24);} |
|
240 |
static final int CENNAM(byte[] b, int pos) { return SH(b, pos + 28);} |
|
241 |
static final int CENEXT(byte[] b, int pos) { return SH(b, pos + 30);} |
|
242 |
static final int CENCOM(byte[] b, int pos) { return SH(b, pos + 32);} |
|
243 |
static final int CENDSK(byte[] b, int pos) { return SH(b, pos + 34);} |
|
244 |
static final int CENATT(byte[] b, int pos) { return SH(b, pos + 36);} |
|
245 |
static final long CENATX(byte[] b, int pos) { return LG(b, pos + 38);} |
|
246 |
static final long CENOFF(byte[] b, int pos) { return LG(b, pos + 42);} |
|
6699
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
247 |
|
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
248 |
/* The END header is followed by a variable length comment of size < 64k. */ |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
249 |
static final long END_MAXLEN = 0xFFFF + ENDHDR; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
250 |
static final int READBLOCKSZ = 128; |
d8229570529d
6990846: Demo: NIO.2 filesystem provider for zip/jar archives
sherman
parents:
diff
changeset
|
251 |
} |