[jcifs] smbFile.list/listFiles - 'max' type setting?

Sebastian Sickelmann sebastian.sickelmann at gmx.de
Tue Nov 22 21:01:59 MST 2011

Am 22.11.2011 16:40, schrieb Darren Hartford:
> Hey all,
> I'm using the great features of jcifs, and the smbFile.list() and smbFile.listFiles(), both with filters.
> However, I only want to work on a portion of files at a time, but it appears (even with the filters set) it spends a lot of time spinning through all the files in a directory instead of only the (first) X amount I want to look at.
> My process I move files out of the directory after review, so I know they will be moved out so I can look at the next 'X' amount.
> Question: Is there a way to limit/stop looking for files after a set number that prevents further processing?  The filters themselves still review each file, while I would rather under-the-covers just stop checking all together after a set number.
> Usecase: a directory with 100k files, looking at 10 files at a time (either through smbFile.list or smbFile.listFile, latter is my primary usage), but still spins through all 100k files per 10 file review.
> thanks for any ideas/feedback,
> -D
I think you are searching for something similar to a DirectoryStream[0] 
but for jcifs. There is no implementation or trick i know that supports 
it on top of jcifs.
In general it should be implementable in parsing through the already 
received results("SMB-Packages") while the directoryScan is still in 
progress and provide some Callback-Interface which is used to push  the 
received results into. But i think there are some major refactorings to 
the threading model that must be done to implement this in a safe way.

Kind regards


More information about the jCIFS mailing list