KC Baltz <[EMAIL PROTECTED]> wrote:
> I think it'd be a useful addition.  My only suggestion would be change the
> parameter name to "forceoverwrite" so it matches the similar parameter in
> <copydir>.
> 
> K.C.

Thanks for the tip - I did the changes to the code.
How does it work from now on?
If I understood it the right way, now a committer would have to include my
code or decide not to do it...

Anyway here it is:

regards

uli stehling

package org.apache.tools.ant.taskdefs;

import org.apache.tools.ant.*;

import java.io.*;
import java.util.*;

public class Copyfile extends Task {

    private File srcFile;
    private File destFile;
    private boolean filtering = false;
    private boolean forceOverwrite = false;

    public void setSrc(String src) {
        srcFile = project.resolveFile(src);
    }

    public void setDest(String dest) {
        destFile = project.resolveFile(dest);
    }

    public void setFiltering(String filter) {
        filtering = Project.toBoolean(filter);
    }

    public void setForceoverwrite(String force) {
                forceOverwrite = Project.toBoolean(force);
    }

    public void execute() throws BuildException {
                if (forceOverwrite ||
                (srcFile.lastModified() > destFile.lastModified())) {
                        try {
                                project.copyFile(srcFile, destFile, filtering, 
forceOverwrite);
                        } catch (IOException ioe) {
                                String msg = "Error copying file: " + 
srcFile.getAbsolutePath()
                                        + " due to " + ioe.getMessage();
                                throw new BuildException(msg);
                        }
                }
        }
}



____________________________________________________________________
Get your own FREE, personal Netscape WebMail account today at 
http://webmail.netscape.com.

Reply via email to