"Harmeet Bedi[yahoo]" wrote:
> 
> The originnal <DirectoryFileFilter> returned all the files, not the
> subdirectories from parent directory. The problem is that the
> DirectoryFileFilter, is checking the parent directory not the child node.
> Well anyway, the modified code is working for me and the originnal did not.
> 
> Hers is a JUnit like test
> File directory = ....
> File[] subdir = directory.listFiles(new DirectoryFileFilter());
> for ( int i = 0 ; i < subdir.length ; i++ ) {
>   // assert( <string>, <assertion check>);
>   assert(subdir[i].getAbsolutePath(),subdir[i].isDirectory());
> }
> 
> Have I got the test wrong ?
> If you point to a directory that has subdirectories and files, the test
> would fail with originnal code.

You know what, I looked at the thing backwards.  I appologize for that.
I am so used to seeing the current version first and the modified version
second, that I didn't even pay attention to the titles above the code
snippets.

> 
> Harmeet
> 
> ----- Original Message -----
> From: "Berin Loritsch" <[EMAIL PROTECTED]>
> To: "Avalon Development" <[EMAIL PROTECTED]>
> Sent: Monday, March 12, 2001 10:51 AM
> Subject: Re: possible bug in DirectroryFileFilter
> 
> > "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: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to