bodewig 2003/05/19 07:43:17
Modified: src/main/org/apache/tools/ant/taskdefs Copy.java Move.java
Log:
Don't remove basedirectories of <fileset>s that just happen to be
matched completely.
PR: 18886
Revision Changes Path
1.56 +3 -2 ant/src/main/org/apache/tools/ant/taskdefs/Copy.java
Index: Copy.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Copy.java,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- Copy.java 28 Mar 2003 08:06:53 -0000 1.55
+++ Copy.java 19 May 2003 14:43:17 -0000 1.56
@@ -391,7 +391,8 @@
String[] srcFiles = ds.getIncludedFiles();
String[] srcDirs = ds.getIncludedDirectories();
- boolean isEverythingIncluded = ds.isEverythingIncluded();
+ boolean isEverythingIncluded = ds.isEverythingIncluded()
+ && (!fs.hasSelectors() && !fs.hasPatterns());
if (isEverythingIncluded
&& !flatten && mapperElement == null) {
completeDirMap.put(fromDir, destDir);
1.34 +1 -66 ant/src/main/org/apache/tools/ant/taskdefs/Move.java
Index: Move.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Move.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- Move.java 27 Mar 2003 16:32:18 -0000 1.33
+++ Move.java 19 May 2003 14:43:17 -0000 1.34
@@ -213,71 +213,6 @@
+ destDir.getAbsolutePath());
}
}
-
- if (filesets.size() > 0) {
- Enumeration e = filesets.elements();
- while (e.hasMoreElements()) {
- FileSet fs = (FileSet) e.nextElement();
- File dir = fs.getDir(getProject());
-
- if (okToDelete(dir)) {
- deleteDir(dir);
- }
- }
- }
- }
-
- /**
- * Its only ok to delete a directory tree if there are
- * no files in it.
- * @return true if a deletion can go ahead
- */
- protected boolean okToDelete(File d) {
- String[] list = d.list();
- if (list == null) {
- return false;
- } // maybe io error?
-
- for (int i = 0; i < list.length; i++) {
- String s = list[i];
- File f = new File(d, s);
- if (f.isDirectory()) {
- if (!okToDelete(f)) {
- return false;
- }
- } else {
- return false; // found a file
- }
- }
-
- return true;
- }
-
- /**
- * Go and delete the directory tree.
- */
- protected void deleteDir(File d) {
- String[] list = d.list();
- if (list == null) {
- return;
- } // on an io error list() can return null
-
- for (int i = 0; i < list.length; i++) {
- String s = list[i];
- File f = new File(d, s);
- if (f.isDirectory()) {
- deleteDir(f);
- } else {
- throw new BuildException("UNEXPECTED ERROR - The file "
- + f.getAbsolutePath()
- + " should not exist!");
- }
- }
- log("Deleting directory " + d.getAbsolutePath(), verbosity);
- if (!d.delete()) {
- throw new BuildException("Unable to delete directory "
- + d.getAbsolutePath());
- }
}
/**