diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java index fc66571c4..d65347d38 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java @@ -267,10 +267,10 @@ public class Zip extends MatchingTask { throws IOException { ZipScanner zipScanner = (ZipScanner) ds; - String zipSrc = fs.getSrc(); + File zipSrc = fs.getSrc(); ZipEntry entry; - ZipInputStream in = new ZipInputStream(new FileInputStream(new File(zipSrc))); + ZipInputStream in = new ZipInputStream(new FileInputStream(zipSrc)); while ((entry = in.getNextEntry()) != null) { String vPath = entry.getName(); if (zipScanner.match(vPath)) { diff --git a/src/main/org/apache/tools/ant/types/FileSet.java b/src/main/org/apache/tools/ant/types/FileSet.java index b3eeb2915..33469a303 100644 --- a/src/main/org/apache/tools/ant/types/FileSet.java +++ b/src/main/org/apache/tools/ant/types/FileSet.java @@ -260,7 +260,7 @@ public class FileSet extends DataType { * Performs the check for circular references and returns the * referenced FileSet. */ - private FileSet getRef(Project p) { + protected FileSet getRef(Project p) { if (!checked) { Stack stk = new Stack(); stk.push(this); diff --git a/src/main/org/apache/tools/ant/types/ZipFileSet.java b/src/main/org/apache/tools/ant/types/ZipFileSet.java index 1eaab74a6..7f679326c 100644 --- a/src/main/org/apache/tools/ant/types/ZipFileSet.java +++ b/src/main/org/apache/tools/ant/types/ZipFileSet.java @@ -79,7 +79,7 @@ import org.apache.tools.ant.Project; */ public class ZipFileSet extends FileSet { - private String srcFileName = null; + private File srcFile = null; private String prefix = ""; private String fullpath = ""; private boolean hasDir = false; @@ -89,7 +89,7 @@ public class ZipFileSet extends FileSet { * from being specified. */ public void setDir(File dir) throws BuildException { - if (srcFileName != null) { + if (srcFile != null) { throw new BuildException("Cannot set both dir and src attributes"); } else { super.setDir(dir); @@ -98,16 +98,16 @@ public class ZipFileSet extends FileSet { } /** - * Set the source Zip file for the zipfileset. Prevents both "dir" and "src" - * from being specified. + * Set the source Zip file for the zipfileset. Prevents both + * "dir" and "src" from being specified. * - * @param srcFileName The zip file from which to extract entries. + * @param srcFile The zip file from which to extract entries. */ - public void setSrc(String srcFileName) { + public void setSrc(File srcFile) { if (hasDir) { throw new BuildException("Cannot set both dir and src attributes"); } - this.srcFileName = srcFileName; + this.srcFile = srcFile; } /** @@ -115,8 +115,8 @@ public class ZipFileSet extends FileSet { * References are not followed, since it is not possible * to have a reference to a ZipFileSet, only to a FileSet. */ - public String getSrc() { - return srcFileName; + public File getSrc() { + return srcFile; } /** @@ -162,12 +162,10 @@ public class ZipFileSet extends FileSet { if (isReference()) { return getRef(p).getDirectoryScanner(p); } - if (srcFileName != null) { + if (srcFile != null) { ZipScanner zs = new ZipScanner(); - zs.setSrc(srcFileName); - if (getDir(p) == null) { - super.setDir(new File(".")); - } + zs.setSrc(srcFile); + super.setDir(new File(".")); setupDirectoryScanner(zs, p); zs.init(); return zs; @@ -176,24 +174,4 @@ public class ZipFileSet extends FileSet { } } - /** - * Performs the check for circular references and returns the - * referenced FileSet. - */ - private FileSet getRef(Project p) { - if (!checked) { - Stack stk = new Stack(); - stk.push(this); - dieOnCircularReference(stk, p); - } - - Object o = ref.getReferencedObject(p); - if (!(o instanceof FileSet)) { - String msg = ref.getRefId()+" doesn\'t denote a fileset"; - throw new BuildException(msg); - } else { - return (FileSet) o; - } - } - } diff --git a/src/main/org/apache/tools/ant/types/ZipScanner.java b/src/main/org/apache/tools/ant/types/ZipScanner.java index 16952232d..85178f1fd 100644 --- a/src/main/org/apache/tools/ant/types/ZipScanner.java +++ b/src/main/org/apache/tools/ant/types/ZipScanner.java @@ -74,7 +74,7 @@ public class ZipScanner extends DirectoryScanner { /** * The zip file which should be scanned. */ - protected String srcFile; + protected File srcFile; /** * Sets the srcFile for scanning. This is the jar or zip file that is scanned @@ -82,7 +82,7 @@ public class ZipScanner extends DirectoryScanner { * * @param srcFile the (non-null) zip file name for scanning */ - public void setSrc(String srcFile) { + public void setSrc(File srcFile) { this.srcFile = srcFile; } @@ -95,7 +95,7 @@ public class ZipScanner extends DirectoryScanner { */ public String[] getIncludedFiles() { String[] result = new String[1]; - result[0] = srcFile; + result[0] = srcFile.getAbsolutePath(); return result; }