|
|
@@ -213,71 +213,6 @@ public class Move extends Copy { |
|
|
|
+ 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()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|