[jcifs] smbfile.listFiles() for only directories

Michael B Allen mba2000 at ioplex.com
Fri Sep 17 18:42:28 GMT 2004


Please send all messages to the jCIFS mailing list.

On Fri, 17 Sep 2004 08:19:09 -0600
"MacDermid, Kenny" <kenny.macdermid at abridean.com> wrote:
> >> I'm looking for a way to have jcifs only list directories
> >> on a listFiles().
> > 
> > Not all filesystems support directory filtering. Is the 
> > remote system NTFS?
> >
> > You could try to write a quick and dirty 
> > Win32 program using FindFirstFileEx with 
> > FindExSearchLimitToDirectories to verify the JCIFS behavior 
> > is correct.
> 
> Hrm... the remote filesystem is NTFS, and I'll take your word on this
> being the correct behaviour.
> 
> So am I back to isDirectory() on each of the files returned, or is there
> any other way I can ask for it that would either move the processing to
> the server, or during list creation?

Extend DosFileFilter and overload accept with:

    boolean accept(SmbFile file) {
        return (file.getAttributes() & attributes) != 0;
    }

and use the said technique with your new filter.

Knowing that servers may ignore some file attributes I will incorporate
this change into DosFileFilter to assert the desired files are returned.

> 
> Also, does the ATTR_HIDDEN hide $ shares (it doesn't appear to). Do I have
> to filter then myself as well?

No. Originally it did but it was decided that hiding things is the
business of a UI. Again the technique previously described using
DosFileFilter will not return hidden files if ATTR_HIDDEN is not
specified.

Mike

-- 
Greedo shoots first? Not in my Star Wars.


More information about the jcifs mailing list