You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by ma...@pncbank.com on 2003/05/22 14:41:04 UTC

FIleset for files a user has permission to read

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


Re: FIleset for files a user has permission to read

Posted by peter reilly <pe...@corvil.com>.
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