| @@ -23,7 +23,7 @@ package org.apache.tools.zip; | |||||
| * | * | ||||
| * @since Ant 1.9.0 | * @since Ant 1.9.0 | ||||
| */ | */ | ||||
| public final class GeneralPurposeBit { | |||||
| public final class GeneralPurposeBit implements Cloneable { | |||||
| /** | /** | ||||
| * Indicates that the file is encrypted. | * Indicates that the file is encrypted. | ||||
| */ | */ | ||||
| @@ -168,4 +168,14 @@ public final class GeneralPurposeBit { | |||||
| && g.languageEncodingFlag == languageEncodingFlag | && g.languageEncodingFlag == languageEncodingFlag | ||||
| && g.dataDescriptorFlag == dataDescriptorFlag; | && g.dataDescriptorFlag == dataDescriptorFlag; | ||||
| } | } | ||||
| @Override | |||||
| public Object clone() { | |||||
| try { | |||||
| return super.clone(); | |||||
| } catch (CloneNotSupportedException ex) { | |||||
| // impossible | |||||
| throw new RuntimeException("GeneralPurposeBit is not Cloneable?", ex); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -136,6 +136,9 @@ public class ZipEntry extends java.util.zip.ZipEntry implements Cloneable { | |||||
| setInternalAttributes(entry.getInternalAttributes()); | setInternalAttributes(entry.getInternalAttributes()); | ||||
| setExternalAttributes(entry.getExternalAttributes()); | setExternalAttributes(entry.getExternalAttributes()); | ||||
| setExtraFields(entry.getExtraFields(true)); | setExtraFields(entry.getExtraFields(true)); | ||||
| setPlatform(entry.platform); | |||||
| setGeneralPurposeBit(entry.gpb == null ? null : | |||||
| (GeneralPurposeBit) entry.gpb.clone()); | |||||
| } | } | ||||
| /** | /** | ||||
| @@ -215,4 +215,14 @@ public class ZipEntryTest { | |||||
| ZipEntry entry2 = new ZipEntry("bar"); | ZipEntry entry2 = new ZipEntry("bar"); | ||||
| assertFalse(entry1.equals(entry2)); | assertFalse(entry1.equals(entry2)); | ||||
| } | } | ||||
| @Test | |||||
| public void testCopyConstructor() throws Exception { | |||||
| ZipEntry archiveEntry = new ZipEntry("fred"); | |||||
| archiveEntry.setUnixMode(0664); | |||||
| archiveEntry.setMethod(ZipEntry.DEFLATED); | |||||
| archiveEntry.getGeneralPurposeBit().useStrongEncryption(true); | |||||
| ZipEntry copy = new ZipEntry(archiveEntry); | |||||
| assertEquals(archiveEntry, copy); | |||||
| } | |||||
| } | } | ||||