[jcifs] returning file properties with SmbFile.list()

Michael B. Allen mballen at erols.com
Sun Sep 23 19:22:42 EST 2001


On Sun, Sep 23, 2001 at 04:34:39AM -0400, Bruce Altner wrote:
> asked...I am generating lists of files on different  shares and want to 
> show other information besides the file name, such as type (file or 
> directory), size, date, etc. List() only returns the file names (as a 
> String[]). As a workaround I've had to iterate over the array of names, 
> instantiating SmbFile for each file in order to get the attributes that I 
> need using the isDirectory(), length(), lastmodified() methods. It works 
> but it is very slow. I tried to extend SmbFile with a listAll() method to 
> get all the properties on one pass but was unsuccessful.

Nope. You can't do it. Not yet anyway. In the future there will be these
additional methods addes to SmbFile:

SmbFile[] listSmbFiles()
SmbFile[] listSmbFiles( SmbFileFilter filter )
SmbFile[] listSmbFiles( SmbFilenameFilter filter )

They will be symmetric with the analogous methods of the
java.io.File class. And, yes it will be much much faster because
the TRANS2_FIND_FIRST2/NEXT2 listing operation returns all of this
information. The CIFS protocol also supportes primarive filters
(e.g. *.exe).

> How are others doing this? It must be a very common need.

Surprisingly no one has brought it up, but it has been on my list for
a long time. I just wanted to get a really stable client out the door
first. I believe we've done that so it will be addresses during the
next iteration.

> Meanwhile, I am very excited about what jCIFS can do for the project I'm 
> working on. I had been wrapping servlet code around calls to smbclient but 
> jCIFS seems like a much better way to go.

Yeah, you're definately better off with jCIFS in this case.

Mike




More information about the jcifs mailing list