Re: JCIFS pagination
Michael B Allen <[email protected]> Sun, 26 Oct 2014 01:22:22 -0400
| Newsgroups | gmane.network.samba.java |
|---|---|
| Message-ID | <CAGMFw4gXqmPO+sNc-XtjD6Ch4P7FKwuU3rCko3aNJB97AU32Zg@mail.gmail.com> |
On Wed, Oct 22, 2014 at 6:49 PM, Sridhar Jonnalagadda <[email protected]> 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). Mike -- Michael B Allen Java Active Directory Integration http://www.ioplex.com/