|
|
@@ -182,8 +182,8 @@ public class ZipFile { |
|
|
|
archive = new RandomAccessFile(f, "r"); |
|
|
|
boolean success = false; |
|
|
|
try { |
|
|
|
Map entriesWithoutEFS = populateFromCentralDirectory(); |
|
|
|
resolveLocalFileHeaderData(entriesWithoutEFS); |
|
|
|
Map entriesWithoutUTF8Flag = populateFromCentralDirectory(); |
|
|
|
resolveLocalFileHeaderData(entriesWithoutUTF8Flag); |
|
|
|
success = true; |
|
|
|
} finally { |
|
|
|
if (!success) { |
|
|
@@ -308,7 +308,7 @@ public class ZipFile { |
|
|
|
*/ |
|
|
|
private Map populateFromCentralDirectory() |
|
|
|
throws IOException { |
|
|
|
HashMap noEFS = new HashMap(); |
|
|
|
HashMap noUTF8Flag = new HashMap(); |
|
|
|
|
|
|
|
positionAtCentralDirectory(); |
|
|
|
|
|
|
@@ -334,10 +334,10 @@ public class ZipFile { |
|
|
|
off += SHORT; // skip version info |
|
|
|
|
|
|
|
final int generalPurposeFlag = ZipShort.getValue(cfh, off); |
|
|
|
final boolean hasEFS = |
|
|
|
(generalPurposeFlag & ZipOutputStream.EFS_FLAG) != 0; |
|
|
|
final boolean hasUTF8Flag = |
|
|
|
(generalPurposeFlag & ZipOutputStream.UFT8_NAMES_FLAG) != 0; |
|
|
|
final ZipEncoding entryEncoding = |
|
|
|
hasEFS ? ZipEncodingHelper.UTF8_ZIP_ENCODING : zipEncoding; |
|
|
|
hasUTF8Flag ? ZipEncodingHelper.UTF8_ZIP_ENCODING : zipEncoding; |
|
|
|
|
|
|
|
off += SHORT; |
|
|
|
|
|
|
@@ -400,11 +400,11 @@ public class ZipFile { |
|
|
|
archive.readFully(signatureBytes); |
|
|
|
sig = ZipLong.getValue(signatureBytes); |
|
|
|
|
|
|
|
if (!hasEFS && useUnicodeExtraFields) { |
|
|
|
noEFS.put(ze, new NameAndComment(fileName, comment)); |
|
|
|
if (!hasUTF8Flag && useUnicodeExtraFields) { |
|
|
|
noUTF8Flag.put(ze, new NameAndComment(fileName, comment)); |
|
|
|
} |
|
|
|
} |
|
|
|
return noEFS; |
|
|
|
return noUTF8Flag; |
|
|
|
} |
|
|
|
|
|
|
|
private static final int MIN_EOCD_SIZE = |
|
|
@@ -499,7 +499,7 @@ public class ZipFile { |
|
|
|
* <p>Also records the offsets for the data to read from the |
|
|
|
* entries.</p> |
|
|
|
*/ |
|
|
|
private void resolveLocalFileHeaderData(Map entriesWithoutEFS) |
|
|
|
private void resolveLocalFileHeaderData(Map entriesWithoutUTF8Flag) |
|
|
|
throws IOException { |
|
|
|
Enumeration e = getEntries(); |
|
|
|
while (e.hasMoreElements()) { |
|
|
@@ -531,10 +531,10 @@ public class ZipFile { |
|
|
|
offsetEntry.dataOffset = offset + LFH_OFFSET_FOR_FILENAME_LENGTH |
|
|
|
+ SHORT + SHORT + fileNameLen + extraFieldLen; |
|
|
|
|
|
|
|
if (entriesWithoutEFS.containsKey(ze)) { |
|
|
|
if (entriesWithoutUTF8Flag.containsKey(ze)) { |
|
|
|
setNameAndCommentFromExtraFields(ze, |
|
|
|
(NameAndComment) |
|
|
|
entriesWithoutEFS.get(ze)); |
|
|
|
entriesWithoutUTF8Flag.get(ze)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|