Submitted by: David Rees <d.rees.l@usa.net> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268772 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -25,9 +25,37 @@ | |||||
| basedir="."/> | basedir="."/> | ||||
| </target> | </target> | ||||
| <target name="test5"> | |||||
| <zip zipfile="test5.zip" basedir="." > | |||||
| <exclude name="test5.zip" /> | |||||
| </zip> | |||||
| </target> | |||||
| <target name="test6"> | |||||
| <zip zipfile="test6.zip" basedir="."> | |||||
| <include name="*.xml" /> | |||||
| <exclude name="zip.*" /> | |||||
| </zip> | |||||
| </target> | |||||
| <target name="test7"> | |||||
| <zip zipfile="inner7.zip" basedir="." > | |||||
| <exclude name="inner7.zip" /> | |||||
| </zip> | |||||
| <zip zipfile="test7.zip" basedir="."> | |||||
| <exclude name="**/*.*" /> | |||||
| <zipfileset src="inner7.zip" /> | |||||
| </zip> | |||||
| </target> | |||||
| <target name="cleanup"> | <target name="cleanup"> | ||||
| <delete file="test3.zip"/> | <delete file="test3.zip"/> | ||||
| <delete file="test4.zip"/> | <delete file="test4.zip"/> | ||||
| <delete file="test5.zip"/> | |||||
| <delete file="test6.zip"/> | |||||
| <delete file="inner7.zip"/> | |||||
| <delete file="test7.zip"/> | |||||
| </target> | </target> | ||||
| </project> | </project> | ||||
| @@ -270,15 +270,23 @@ public class Zip extends MatchingTask { | |||||
| File zipSrc = fs.getSrc(); | File zipSrc = fs.getSrc(); | ||||
| ZipEntry entry; | ZipEntry entry; | ||||
| ZipInputStream in = new ZipInputStream(new FileInputStream(zipSrc)); | |||||
| while ((entry = in.getNextEntry()) != null) { | |||||
| String vPath = entry.getName(); | |||||
| if (zipScanner.match(vPath)) { | |||||
| addParentDirs(null, vPath, zOut, prefix); | |||||
| if (! entry.isDirectory()) { | |||||
| zipFile(in, zOut, prefix+vPath, entry.getTime()); | |||||
| ZipInputStream in = null; | |||||
| try { | |||||
| in = new ZipInputStream(new FileInputStream(zipSrc)); | |||||
| while ((entry = in.getNextEntry()) != null) { | |||||
| String vPath = entry.getName(); | |||||
| if (zipScanner.match(vPath)) { | |||||
| addParentDirs(null, vPath, zOut, prefix); | |||||
| if (! entry.isDirectory()) { | |||||
| zipFile(in, zOut, prefix+vPath, entry.getTime()); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| } finally { | |||||
| if (in != null) { | |||||
| in.close(); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -87,4 +87,17 @@ public class ZipTest extends TaskdefsTest { | |||||
| executeTarget("cleanup"); | executeTarget("cleanup"); | ||||
| } | } | ||||
| public void test5() { | |||||
| executeTarget("test5"); | |||||
| } | |||||
| public void test6() { | |||||
| executeTarget("test6"); | |||||
| } | |||||
| public void test7() { | |||||
| executeTarget("test7"); | |||||
| } | |||||
| } | } | ||||