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" classname="ReadOnlySelector" classpath="build/classes" />
<copy todir="build/copy"> <fileset dir="src"> <readonly/> </fileset> </copy>
Where ReadOnlySelector is this:
import org.apache.tools.ant.types.selectors.FileSelector; import org.apache.tools.ant.BuildException;
import java.io.File;
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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]