[jcifs] Printers showing up as TYPE_SHARE

Michael Kerley michael at enkoo.com
Tue Jun 7 23:13:13 GMT 2005


Hi,
I found that when I use the SmbFile.listFiles() method at the server level,
all of the returned files have the TYPE_SHARE type, even if they're actually
printers or named pipes.
 
I combined the jCIFS standard List and GetType examples to make a
ListWithTypes program.  Using that program, if I do this:
 
  java ListWithTypes smb://MyComputer/
 
The result looks like this:

  share1     TYPE_SHARE
  share2     TYPE_SHARE
  share3     TYPE_SHARE
  printer1   TYPE_SHARE
  IPC$       TYPE_SHARE

This is true in jCIFS 0.9.6-current.  I don't know about all the versions
before that, but I think it used to work correctly in 0.7.19.  Anyway, I
made the following change to the source:

  SmbFile.java, lines 1634-1636 in version 1.2.0

    // Standard version
    SmbFile f = new SmbFile( this, name,
                listType == 0 ? TYPE_WORKGROUP : (listType << 1),
                ATTR_READONLY | ATTR_DIRECTORY, 0L, 0L, 0L );

    // My version
    SmbFile f = new SmbFile( this, name,
                e.getType(),
                ATTR_READONLY | ATTR_DIRECTORY, 0L, 0L, 0L );

After making that change, my results look like this:

  share1     TYPE_SHARE
  share2     TYPE_SHARE
  share3     TYPE_SHARE
  printer1   TYPE_PRINTER
  IPC$       TYPE_NAMED_PIPE

Would there be any negative side effects to such a change that I'm not
seeing?  If not, I'd like to contribute  this change to the project as a
patch.

Thanks
Michael Kerley



More information about the jcifs mailing list