< prev index next >

src/java.base/share/classes/java/util/zip/ZipFile.java

Print this page
8203328: Rename EFS in java.util.zip internals to something meaningful
Reviewed-by: sherman

*** 375,385 **** Set<InputStream> istreams = res.istreams; synchronized (this) { ensureOpen(); if (Objects.equals(lastEntryName, entry.name)) { pos = lastEntryPos; ! } else if (!zc.isUTF8() && (entry.flag & EFS) != 0) { pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false); } else { pos = zsrc.getEntryPos(zc.getBytes(entry.name), false); } if (pos == -1) { --- 375,385 ---- Set<InputStream> istreams = res.istreams; synchronized (this) { ensureOpen(); if (Objects.equals(lastEntryName, entry.name)) { pos = lastEntryPos; ! } else if (!zc.isUTF8() && (entry.flag & USE_UTF8) != 0) { pos = zsrc.getEntryPos(zc.getBytesUTF8(entry.name), false); } else { pos = zsrc.getEntryPos(zc.getBytes(entry.name), false); } if (pos == -1) {
*** 603,613 **** } private String getEntryName(int pos) { byte[] cen = res.zsrc.cen; int nlen = CENNAM(cen, pos); ! if (!zc.isUTF8() && (CENFLG(cen, pos) & EFS) != 0) { return zc.toStringUTF8(cen, pos + CENHDR, nlen); } else { return zc.toString(cen, pos + CENHDR, nlen); } } --- 603,613 ---- } private String getEntryName(int pos) { byte[] cen = res.zsrc.cen; int nlen = CENNAM(cen, pos); ! if (!zc.isUTF8() && (CENFLG(cen, pos) & USE_UTF8) != 0) { return zc.toStringUTF8(cen, pos + CENHDR, nlen); } else { return zc.toString(cen, pos + CENHDR, nlen); } }
*** 663,673 **** if (name == null || bname.length != nlen) { // to use the entry name stored in cen, if the passed in name is // (1) null, invoked from iterator, or // (2) not equal to the name stored, a slash is appended during // getEntryPos() search. ! if (!zc.isUTF8() && (flag & EFS) != 0) { name = zc.toStringUTF8(cen, pos + CENHDR, nlen); } else { name = zc.toString(cen, pos + CENHDR, nlen); } } --- 663,673 ---- if (name == null || bname.length != nlen) { // to use the entry name stored in cen, if the passed in name is // (1) null, invoked from iterator, or // (2) not equal to the name stored, a slash is appended during // getEntryPos() search. ! if (!zc.isUTF8() && (flag & USE_UTF8) != 0) { name = zc.toStringUTF8(cen, pos + CENHDR, nlen); } else { name = zc.toString(cen, pos + CENHDR, nlen); } }
*** 682,692 **** int start = pos + CENHDR + nlen; e.setExtra0(Arrays.copyOfRange(cen, start, start + elen), true); } if (clen != 0) { int start = pos + CENHDR + nlen + elen; ! if (!zc.isUTF8() && (flag & EFS) != 0) { e.comment = zc.toStringUTF8(cen, start, clen); } else { e.comment = zc.toString(cen, start, clen); } } --- 682,692 ---- int start = pos + CENHDR + nlen; e.setExtra0(Arrays.copyOfRange(cen, start, start + elen), true); } if (clen != 0) { int start = pos + CENHDR + nlen + elen; ! if (!zc.isUTF8() && (flag & USE_UTF8) != 0) { e.comment = zc.toStringUTF8(cen, start, clen); } else { e.comment = zc.toString(cen, start, clen); } }
*** 982,992 **** } off += sz; } } ! /* The Zip file spec explicitly allows the LOC extra data size to * be different from the CEN extra data size. Since we cannot trust * the CEN extra data size, we need to read the LOC to determine * the entry data offset. */ private long initDataOffset() throws IOException { --- 982,993 ---- } off += sz; } } ! /* ! * The Zip file spec explicitly allows the LOC extra data size to * be different from the CEN extra data size. Since we cannot trust * the CEN extra data size, we need to read the LOC to determine * the entry data offset. */ private long initDataOffset() throws IOException {
*** 1287,1297 **** private static final int BUF_SIZE = 8192; private final int readFullyAt(byte[] buf, int off, int len, long pos) throws IOException { ! synchronized(zfile) { zfile.seek(pos); int N = len; while (N > 0) { int n = Math.min(BUF_SIZE, N); zfile.readFully(buf, off, n); --- 1288,1298 ---- private static final int BUF_SIZE = 8192; private final int readFullyAt(byte[] buf, int off, int len, long pos) throws IOException { ! synchronized (zfile) { zfile.seek(pos); int N = len; while (N > 0) { int n = Math.min(BUF_SIZE, N); zfile.readFully(buf, off, n);
*** 1303,1313 **** } private final int readAt(byte[] buf, int off, int len, long pos) throws IOException { ! synchronized(zfile) { zfile.seek(pos); return zfile.read(buf, off, len); } } --- 1304,1314 ---- } private final int readAt(byte[] buf, int off, int len, long pos) throws IOException { ! synchronized (zfile) { zfile.seek(pos); return zfile.read(buf, off, len); } }
*** 1542,1552 **** * This while loop is an optimization where a double lookup * for name and name+/ is being performed. The name char * array has enough room at the end to try again with a * slash appended if the first table lookup does not succeed. */ ! while(true) { /* * Search down the target hash chain for a entry whose * 32 bit hash matches the hashed name. */ while (idx != ZIP_ENDCHAIN) { --- 1543,1553 ---- * This while loop is an optimization where a double lookup * for name and name+/ is being performed. The name char * array has enough room at the end to try again with a * slash appended if the first table lookup does not succeed. */ ! while (true) { /* * Search down the target hash chain for a entry whose * 32 bit hash matches the hashed name. */ while (idx != ZIP_ENDCHAIN) {
< prev index next >