Browse Source

Detect situations when files and directories cannot be deleted.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267716 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 25 years ago
parent
commit
7dff158a65
2 changed files with 15 additions and 1 deletions
  1. +6
    -0
      src/main/org/apache/tools/ant/taskdefs/Delete.java
  2. +9
    -1
      src/main/org/apache/tools/ant/taskdefs/Deltree.java

+ 6
- 0
src/main/org/apache/tools/ant/taskdefs/Delete.java View File

@@ -124,6 +124,9 @@ public class Delete extends MatchingTask {
else {
project.log("Deleting: " + f.getAbsolutePath());
f.delete();
if (f.exists()) {
throw new BuildException("Unable to delete file " + f.getAbsolutePath());
}
}
}
}
@@ -146,6 +149,9 @@ public class Delete extends MatchingTask {
if (f.exists()) {
project.log("Deleting: " + f.getAbsolutePath(), verbosity);
f.delete();
if (f.exists()) {
throw new BuildException("Unable to delete " + f.getAbsolutePath());
}
}
}
}


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

@@ -77,6 +77,9 @@ public class Deltree extends Task {
if (dir.exists()) {
if (!dir.isDirectory()) {
dir.delete();
if (dir.exists()) {
throw new BuildException("Unable to delete file " + dir.getAbsolutePath());
}
return;
// String msg = "Given dir: " + dir.getAbsolutePath() +
// " is not a dir";
@@ -108,10 +111,15 @@ public class Deltree extends Task {
removeDir(f);
} else {
f.delete();
if (f.exists()) {
throw new BuildException("Unable to delete file " + f.getAbsolutePath());
}
}
}
// }
dir.delete();
if (dir.exists()) {
throw new BuildException("Unable to delete directory " + dir.getAbsolutePath());
}
}
}


Loading…
Cancel
Save