Browse Source

more explicit existence chacks in unzip/tar. PR 44843

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@677860 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
e7e99f061c
2 changed files with 12 additions and 0 deletions
  1. +5
    -0
      src/main/org/apache/tools/ant/taskdefs/Expand.java
  2. +7
    -0
      src/main/org/apache/tools/ant/taskdefs/Untar.java

+ 5
- 0
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -122,6 +122,10 @@ public class Expand extends Task {
if (source.isDirectory()) { if (source.isDirectory()) {
throw new BuildException("Src must not be a directory." throw new BuildException("Src must not be a directory."
+ " Use nested filesets instead.", getLocation()); + " Use nested filesets instead.", getLocation());
} else if (!source.exists()) {
throw new BuildException("src '" + source + "' doesn't exist.");
} else if (!source.canRead()) {
throw new BuildException("src '" + source + "' cannot be read.");
} else { } else {
expandFile(FILE_UTILS, source, dest); expandFile(FILE_UTILS, source, dest);
} }
@@ -130,6 +134,7 @@ public class Expand extends Task {
while (iter.hasNext()) { while (iter.hasNext()) {
Resource r = (Resource) iter.next(); Resource r = (Resource) iter.next();
if (!r.isExists()) { if (!r.isExists()) {
log("Skipping '" + r.getName() + "' because it doesn't exist.");
continue; continue;
} }




+ 7
- 0
src/main/org/apache/tools/ant/taskdefs/Untar.java View File

@@ -118,6 +118,13 @@ public class Untar extends Expand {
* @since Ant 1.7 * @since Ant 1.7
*/ */
protected void expandResource(Resource srcR, File dir) { protected void expandResource(Resource srcR, File dir) {
if (!srcR.isExists()) {
throw new BuildException("Unable to untar "
+ srcR.getName()
+ " as the it does not exist",
getLocation());
}

InputStream i = null; InputStream i = null;
try { try {
i = srcR.getInputStream(); i = srcR.getInputStream();


Loading…
Cancel
Save