ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <>
Subject Re: Reading file attributes
Date Tue, 28 Sep 2004 10:22:24 GMT

On Sep 28, 2004, at 5:04 AM, Lennart Hellström (HF/EBC) wrote:
> I want to copy a file to a destination file only if the destination 
> file is not readonly (it might be checked in on the version control 
> system)
> I tried using <copy> with failOnError="false" but strangely the build 
> fails anyway when the destination file is readonly.
> Is there some way to look at the file's attributes before deciding to 
> copy or not?
> <Attrib> seems to only change the file attributes, and that's not what 
> I want.

There may be other ways to do this, but as an example of writing a 
custom selector I do this:

   <typedef name="readonly"

   <copy todir="build/copy">
     <fileset dir="src">

Where ReadOnlySelector is this:



public class ReadOnlySelector implements FileSelector {
   public boolean isSelected(File basedir,
                             String filename,
                             File file) throws BuildException {
     return !file.canWrite() && file.canRead();

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message