avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: possible bug in DirectroryFileFilter
Date Mon, 12 Mar 2001 18:51:12 GMT
"Harmeet Bedi[yahoo]" wrote:
> 
> possible bug in org.apache.avalon.util.io.DirectoryFileFilter
> 
> I think it should be
> ------------------------------
> public class DirectoryFileFilter
>     implements FilenameFilter
> {
>     public boolean accept( final File file, final String name )
>     {
>         return new File(file,name).isDirectory();
>     }
> }
> 
> instead of
> --------------------------------------------------
> public class DirectoryFileFilter
>     implements FilenameFilter
> {
>     public boolean accept( final File file, final String name )
>     {
>         return file.isDirectory();
>     }
> }

The purpose of the FileFilter is to list all directories that are
subdirectories of a File.  So if you only want to list the directories,
you don't test against the parent (which is almost always a directory).
Otherwise, you will get a true value for all children.  Not what we
want.

The DirectoryFileFilter is correct.

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message