Browse Source

Added flatten attribute to <copydir>.

Submitted by:	Jeff Martin <jeff.martin@synamic.co.uk>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267879 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
565b600d95
2 changed files with 18 additions and 1 deletions
  1. +7
    -0
      docs/index.html
  2. +11
    -1
      src/main/org/apache/tools/ant/taskdefs/Copydir.java

+ 7
- 0
docs/index.html View File

@@ -855,6 +855,13 @@ this attribute has been replaced by the <i>excludes</i> attribute.</p>
the copy</td> the copy</td>
<td valign="top" align="center">No</td> <td valign="top" align="center">No</td>
</tr> </tr>
<tr>
<td valign="top">flatten</td>
<td valign="top">ignore directory structure of source directory,
copy all files into a single directory - specified by the dest
attribute (default is false).</td>
<td valign="top" align="center">No</td>
</tr>
<tr> <tr>
<td valign="top">forceoverwrite</td> <td valign="top">forceoverwrite</td>
<td valign="top">overwrite existing files even if the destination <td valign="top">overwrite existing files even if the destination


+ 11
- 1
src/main/org/apache/tools/ant/taskdefs/Copydir.java View File

@@ -70,6 +70,7 @@ public class Copydir extends MatchingTask {
private File srcDir; private File srcDir;
private File destDir; private File destDir;
private boolean filtering = false; private boolean filtering = false;
private boolean flatten = false;
private boolean forceOverwrite = false; private boolean forceOverwrite = false;
private Hashtable filecopyList = new Hashtable(); private Hashtable filecopyList = new Hashtable();


@@ -85,6 +86,10 @@ public class Copydir extends MatchingTask {
filtering = Project.toBoolean(filter); filtering = Project.toBoolean(filter);
} }


public void setFlatten(boolean flatten) {
this.flatten = flatten;
}

public void setForceoverwrite(String force) { public void setForceoverwrite(String force) {
forceOverwrite = Project.toBoolean(force); forceOverwrite = Project.toBoolean(force);
} }
@@ -127,7 +132,12 @@ public class Copydir extends MatchingTask {
for (int i = 0; i < files.length; i++) { for (int i = 0; i < files.length; i++) {
String filename = files[i]; String filename = files[i];
File srcFile = new File(from, filename); File srcFile = new File(from, filename);
File destFile = new File(to, filename);
File destFile;
if (flatten) {
destFile = new File(to, new File(filename).getName());
} else {
destFile = new File(to, filename);
}
if (forceOverwrite || if (forceOverwrite ||
(srcFile.lastModified() > destFile.lastModified())) { (srcFile.lastModified() > destFile.lastModified())) {
filecopyList.put(srcFile.getAbsolutePath(), filecopyList.put(srcFile.getAbsolutePath(),


Loading…
Cancel
Save