[jcifs] Incorrect return from SmbFile.getUncPath()

Michael B. Allen miallen at eskimo.com
Wed Nov 13 19:52:54 EST 2002

On Tue, 12 Nov 2002 03:07:28 -0600
dircha at bethel.edu wrote:

> >I am using jcifs-0.7.0b7.jar (and also found this error in 0b6).
> >
> >I use jcifs.smb.SmbFile.getUncPath() to create a corresponding java.io.File
> >object. The problem is that in the return value the share name is dropped.
> >
> >Given an SmbFile constructed with this string:
> >"smb://BG/SharedDocs/My Music/" where BG is a computer on the network,
> >
> >SmbFile.getUncPath() is returning "\\BG\My Music\".
> >
> >I believe the error is on line 689 of jcifs.smb.SmbFile.java in the
> >getUncPath0() method. The share name is extracted to the member "share", but
> >then the value assigned to the member "unc" begins at the '/' after the share
> >name. The incorrect value in "unc" is then returned to the caller (getUncPath()).
> >
> >--Chad Dirks
> Apologies, I should have tried the suggested solution before posting. Apparently
> the purpose of getUntPath0() is different than I suspected, as making the
> previously suggested change broke several other methods in the class. If the
> behavior I described was incorrect, then I suspect that the same problem occurs
> elsewhere in the class where the value of the member "unc" is used. If someone
> can confirm that this behavior is incorrect, I will test additional methods.
> At least for my immediate purposes however, the correct behavior can be had by
> changing line 706 of jcifs.smb.SmbFile in the getUncPath() method from:
> return "\\\\" + url.getHost() + getUncPath0()
> to:
> return "\\\\" + url.getHost() + '\\' + share + getUncPath0()

Fixed in 0.7.0b8. Thx.

> --Chad Dirks

A  program should be written to model the concepts of the task it
performs rather than the physical world or a process because this
maximizes  the  potential  for it to be applied to tasks that are
conceptually  similar and, more important, to tasks that have not
yet been conceived. 

More information about the jcifs mailing list