ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From peter reilly <peter.rei...@corvil.com>
Subject Re: FIleset for files a user has permission to read
Date Thu, 22 May 2003 13:34:01 GMT
You need to use a custom selector to filter in the readable files.

import org.apache.tools.ant.types.selectors.BaseExtendSelector;
import java.io.File;

/**
 * Selector that filters readable files.
 */
public class ReadableSelector extends BaseExtendSelector {
    public boolean isSelected(File basedir, String filename, File file) {
        return file.canRead();
    }

}

and use:
<project name="t" default="t">
  <target name="t">
    <mkdir dir="classes"/>
    <javac srcdir="src" destdir="classes"/>
    <selector id="readable">
      <custom classname="ReadableSelector" 
              classpath="classes"/>
    </selector>

    <touch file="notreadable"/>
    <chmod perm="ugo-r" file="notreadable"/>
    <fileset id="files" dir="." includes="*">
      <selector refid="readable"/>
    </fileset>

    <pathconvert targetos="unix" property="files.string" refid="files"/>
    <echo message="${files.string}"/>
  </target>
</project>

Peter.

On Thursday 22 May 2003 13:41, mark.russel@pncbank.com wrote:
> I need to create a fileset for a tar task.  However there may be lock files
> in the directory tree that are not owned by the backup user.  these lock
> files are 600 permission and can not be tared up.  This causes ant to
> fail.what I want is a fileset of the files I have permission to read.  I
> spent some time looking though the docs but could not find it.  Any help
> would be appreciated.
>
> Mark Russell
> PNC
> 412-768-9603
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message