[jcifs] JCIFS pagination

Michael B Allen ioplex at gmail.com
Sat Oct 25 23:22:22 MDT 2014

On Wed, Oct 22, 2014 at 6:49 PM, Sridhar Jonnalagadda
<jonnalagadda.sridhar at gmail.com> wrote:
> Hello JCIFS support team,
> We have a requirement where there will be multiple calls, to list contents
> of a folder. From MS-CIFS doc, there are two commands TRANS_FIND_FIRST2 and
> TRANS_FIND_NEXT2 that might be used to retrieve folder contents as pages.
> The listFiles() API in SmbFile is retrieving all the contents as one big
> list. I see the code is using TRANS_FIND_FIRST2 and TRANS_FIND_NEXT2.
> SmbFile does not have API to fulfill the requirement.

Hi Sridhar,

JCIFS commands are already async. And JCIFS is very efficient about
memory and stuff like this. All you need is the
{SmbFileFilter,SmbFilenameFilter}.accept() callback. No need for OOP
and Observable "patterns" and all that jazz.

Although from just glancing at the code, it seems if you throw an
exception from {SmbFileFilter,SmbFilenameFilter}.accept() it will not
properly call SmbComFindClose2. But that is just a bug in the code
that looks fairly easy to fix (by putting the close call in a finally
block). I have added it to the TODO list. But if you really want to
quit the list op early, you can probably still safely throw an
exception in accept(). It might leave a handle open on the server but
it will get cleaned up when the connection closes (after being idle
for 30 seconds).


Michael B Allen
Java Active Directory Integration

More information about the jCIFS mailing list