You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Jeff Martin <je...@synamic.co.uk> on 2000/08/02 11:28:01 UTC

[Patch] Copydir, flattening directory structures

This is something I've had to do for the project I'm working on. It allows
you to specifiy a flatten attribute which makes Copydir ignore the directory
structure for the destination files and copy them all in to the one
directory.

It's probably not really a sensible thing to be doing (Duplicated file
names) but if you need to do it this works.

Index: src/main/org/apache/tools/ant/taskdefs/Copydir.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Copydir.j
ava,v
retrieving revision 1.10
diff -b -B -r1.10 Copydir.java
73a74
>     private boolean flatten = false;
91a93,96
>     public void setFlatten(String flatten) {
>         this.flatten = Project.toBoolean(flatten);
>     }
> 
130c135,140
<             File destFile = new File(to, filename);
---
>             File destFile;
>             if(flatten){
>                 destFile = new File(to, new File(filename).getName());
>             }else{
>                 destFile = new File(to, filename);
>             }