commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edgar Poce <edgarp...@gmail.com>
Subject Re: [VFS] getChildren()
Date Fri, 18 Feb 2005 09:14:35 GMT
Hi mario

thanks for the trick. I'll use it but I think

FileObject[] getChildren(FileSelector selector) throws
  FileSystemException

should be added. In java.io.File you can find listFiles(FileFilter 
filter). I think VFS should have most of the java.io.File features plus 
the advantage of a single api for multiple providers.

Thanks again
Edgar

Mario Ivankovits wrote:
> Edgar Poce wrote:
> 
>> Hi
>>  I want to list only the folder children and I don't find this method 
>> in FileObject class.
>>
>> FileObject[] getChildren(FileTypeSelector selector) throws 
>> FileSystemException
> 
> 
>        final FileObject fo = 
> VFS.getManager().resolveFile("/your/parent/directory");
>        FileObject[] children = fo.findFiles(new 
> FileTypeSelector(FileType.FOLDER)
>        {
>            public boolean includeFile(FileSelectInfo fileSelectInfo) 
> throws FileSystemException
>            {
>                if (fileSelectInfo.getFile() == fo)
>                {
>                    return false;
>                }
>                return super.includeFile(fileSelectInfo);
>            }
> 
>            public boolean traverseDescendents(FileSelectInfo 
> fileSelectInfo)
>            {
>                return fileSelectInfo.getFile() == fo;
>            }
>        });
> 
> Should do the trick.
> 
> For sure - it would be best if you pack the above into your own 
> FileSelector.
> 
> ---
> Mario
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 

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


Mime
View raw message