[jcifs] Equivalent for java.io.File.getCanonicalPath()
Julian Reschke
julian.reschke at gmx.de
Tue Feb 3 16:30:20 GMT 2004
Michael B Allen wrote:
> ...
> I'm not certain what you're explaining here in general but the jCIFS
> client should perfrom canoncialization like any other client or server.
> Canonicalization is just factoring out '..'. That's it. Any other
> components shouldn't have any effect on how paths are resolved on the
> server. There should be no discrepency between how the client and server
> resolve paths. If there is that is a bug in the client or server and in
> either case jCIFS will be coded to emulate Windows 2000. I would not be
> surprised to learn MS servers handle some strange cases in unexpected ways
> (read -- has bugs) but I can only deal with that when it happends. Anyway,
> what's the alternative?
>
> ...
OK,
here are testcases that show the differences in getCanonicalPath for
Filer and SmbFile:
private static void testCanonical() throws IOException {
File f = new File(localfolder + "a");
f.delete();
String smbpath = "smb://" + creds + host + "/" + share + "/";
System.out.println("canon 'a' -> '" + (new File(localfolder +
"a")).getCanonicalPath() + "'");
System.out.println("smb canon 'a' -> '" + (new SmbFile(smbpath +
"a")).getCanonicalPath() + "'");
System.out.println("canon 'A' -> '" + (new File(localfolder +
"A")).getCanonicalPath() + "'");
System.out.println("smb canon 'A' -> '" + (new SmbFile(smbpath +
"A")).getCanonicalPath() + "'");
System.out.println("canon 'A ' -> '" + (new File(localfolder + "A
")).getCanonicalPath() + "'");
System.out.println("smb canon 'A ' -> '" + (new SmbFile(smbpath + "A
")).getCanonicalPath() + "'");
System.out.println("canon 'A\u00a0' -> '" + (new File(localfolder +
"A\u00a0")).getCanonicalPath() + "'");
System.out.println("smb canon 'A\u00a0' -> '" + (new SmbFile(smbpath +
"A\u00a0")).getCanonicalPath() + "'");
f.createNewFile();
System.out.println("canon 'a' -> '" + (new File(localfolder +
"a")).getCanonicalPath() + "'");
System.out.println("smb canon 'a' -> '" + (new SmbFile(smbpath +
"a")).getCanonicalPath() + "'");
System.out.println("canon 'A' -> '" + (new File(localfolder +
"A")).getCanonicalPath() + "'");
System.out.println("smb canon 'A' -> '" + (new SmbFile(smbpath +
"A")).getCanonicalPath() + "'");
System.out.println("canon 'A ' -> '" + (new File(localfolder + "A
")).getCanonicalPath() + "'");
System.out.println("smb canon 'A ' -> '" + (new SmbFile(smbpath + "A
")).getCanonicalPath() + "'");
System.out.println("canon 'A\u00a0' -> '" + (new File(localfolder +
"A\u00a0")).getCanonicalPath() + "'");
System.out.println("smb canon 'A\u00a0' -> '" + (new SmbFile(smbpath +
"A\u00a0")).getCanonicalPath() + "'");
}
yields (host replaced by "..."):
(before creation of 'a')
canon 'a' -> 'C:\smbshare\a'
smb canon 'a' -> 'smb://.../smbshare/a'
canon 'A' -> 'C:\smbshare\A'
smb canon 'A' -> 'smb://.../smbshare/A'
canon 'A ' -> 'C:\smbshare\A'
smb canon 'A ' -> 'smb://.../smbshare/A'
canon 'A ' -> 'C:\smbshare\A '
smb canon 'A ' -> 'smb://.../smbshare/A '
(after creation of 'a')
canon 'a' -> 'C:\smbshare\a'
smb canon 'a' -> 'smb://.../smbshare/a'
canon 'A' -> 'C:\smbshare\a'
smb canon 'A' -> 'smb://.../smbshare/A'
canon 'A ' -> 'C:\smbshare\a'
smb canon 'A ' -> 'smb://.../smbshare/A'
canon 'A ' -> 'C:\smbshare\A '
smb canon 'A ' -> 'smb://.../smbshare/A '
Note that for java.io.File, getCanonicalPath changes it's value
depending on whether a remote file with the same (or "similar") name exists.
Julian
--
<green/>bytes GmbH -- http://www.greenbytes.de -- tel:+492512807760
More information about the jcifs
mailing list