Browse Source

extra diags when expand and untar fail

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@667588 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 17 years ago
parent
commit
613f1f3339
2 changed files with 17 additions and 4 deletions
  1. +9
    -1
      src/main/org/apache/tools/ant/taskdefs/Expand.java
  2. +8
    -3
      src/main/org/apache/tools/ant/taskdefs/Untar.java

+ 9
- 1
src/main/org/apache/tools/ant/taskdefs/Expand.java View File

@@ -133,6 +133,12 @@ public class Expand extends Task {
log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO);
ZipFile zf = null;
FileNameMapper mapper = getMapper();
if (!srcF.exists()) {
throw new BuildException("Unable to expand "
+ srcF
+ " as the file does not exist",
getLocation());
}
try {
zf = new ZipFile(srcF, encoding);
Enumeration e = zf.getEntries();
@@ -296,7 +302,9 @@ public class Expand extends Task {

fileUtils.setFileLastModified(f, entryDate.getTime());
} catch (FileNotFoundException ex) {
log("Unable to expand to file " + f.getPath(), Project.MSG_WARN);
log("Unable to expand to file " + f.getPath(),
ex,
Project.MSG_WARN);
}

}


+ 8
- 3
src/main/org/apache/tools/ant/taskdefs/Untar.java View File

@@ -39,8 +39,6 @@ import org.apache.tools.tar.TarInputStream;

/**
* Untar a file.
* <p>For JDK 1.1 &quot;last modified time&quot; field is set to current time instead of being
* carried from the archive file.</p>
* <p>PatternSets are used to select files to extract
* <I>from</I> the archive. If no patternset is used, all files are extracted.
* </p>
@@ -94,11 +92,18 @@ public class Untar extends Expand {
/** {@inheritDoc} */
protected void expandFile(FileUtils fileUtils, File srcF, File dir) {
FileInputStream fis = null;
if (!srcF.exists()) {
throw new BuildException("Unable to untar "
+ srcF
+ " as the file does not exist",
getLocation());
}
try {
fis = new FileInputStream(srcF);
expandStream(srcF.getPath(), fis, dir);
} catch (IOException ioe) {
throw new BuildException("Error while expanding " + srcF.getPath(),
throw new BuildException("Error while expanding " + srcF.getPath()
+ "\n" + ioe.toString(),
ioe, getLocation());
} finally {
FileUtils.close(fis);


Loading…
Cancel
Save