Author: bodewig
Date: Fri Feb 19 08:47:43 2010
New Revision: 911741
URL: http://svn.apache.org/viewvc?rev=911741&view=rev
Log:
EFS in APPNOTE.TXT stands for 'Early Feature Specification' so our usage of it
as 'use the general purpose field to signal UTF8' is wrong.
Modified:
ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java (contents,
props changed)
ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java
(contents, props changed)
Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java?rev=911741&r1=911740&r2=911741&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java Fri Feb 19
08:47:43 2010
@@ -182,8 +182,8 @@
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 @@
*/
private Map populateFromCentralDirectory()
throws IOException {
- HashMap noEFS = new HashMap();
+ HashMap noUTF8Flag = new HashMap();
positionAtCentralDirectory();
@@ -334,10 +334,10 @@
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 @@
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 @@
* <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 @@
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));
}
}
}
Propchange: ant/core/trunk/src/main/org/apache/tools/zip/ZipFile.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 19 08:47:43 2010
@@ -1 +1,2 @@
+/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:911740
/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java:745920,746933,748133,748556,749342-749344,749524,749603,749855,749859
Modified: ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java?rev=911741&r1=911740&r2=911741&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java Fri Feb
19 08:47:43 2010
@@ -96,11 +96,18 @@
*/
static final String DEFAULT_ENCODING = null;
- /**
+ /**
+ * General purpose flag, which indicates that filenames are
+ * written in utf-8.
+ */
+ public static final int UFT8_NAMES_FLAG = 1 << 11;
+
+ /**
* General purpose flag, which indicates that filenames are
* written in utf-8.
+ * @deprecated use {...@link #UFT8_NAMES_FLAG} instead
*/
- public static final int EFS_FLAG = 1 << 11;
+ public static final int EFS_FLAG = UFT8_NAMES_FLAG;
/**
* Current entry.
@@ -265,9 +272,10 @@
private RandomAccessFile raf = null;
/**
- * whether to use the EFS flag when writing UTF-8 filenames or not.
+ * whether to use the general purpose bit flag when writing UTF-8
+ * filenames or not.
*/
- private boolean useEFS = true;
+ private boolean useUTF8Flag = true;
/**
* Whether to encode non-encodable file names as UTF-8.
@@ -341,7 +349,7 @@
public void setEncoding(final String encoding) {
this.encoding = encoding;
this.zipEncoding = ZipEncodingHelper.getZipEncoding(encoding);
- useEFS &= ZipEncodingHelper.isUTF8(encoding);
+ useUTF8Flag &= ZipEncodingHelper.isUTF8(encoding);
}
/**
@@ -362,7 +370,7 @@
* <p>Defaults to true.</p>
*/
public void setUseLanguageEncodingFlag(boolean b) {
- useEFS = b && ZipEncodingHelper.isUTF8(encoding);
+ useUTF8Flag = b && ZipEncodingHelper.isUTF8(encoding);
}
/**
@@ -1050,7 +1058,7 @@
// CheckStyle:MagicNumber OFF
int versionNeededToExtract = 10;
- int generalPurposeFlag = (useEFS || utfFallback) ? EFS_FLAG : 0;
+ int generalPurposeFlag = (useUTF8Flag || utfFallback) ?
UFT8_NAMES_FLAG : 0;
if (zipMethod == DEFLATED && raf == null) {
// requires version 2 as we are going to store length info
// in the data descriptor
Propchange: ant/core/trunk/src/main/org/apache/tools/zip/ZipOutputStream.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Feb 19 08:47:43 2010
@@ -1 +1,2 @@
+/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java:911740
/commons/sandbox/compress/trunk/src/main/java/org/apache/commons/compress/archivers/zip/ZipArchiveOutputStream.java:745920,747810,747841,748063,749342,749906-749907,750055,750310