T
Tom Anderson
Tom said:Tom Anderson wrote:
Also, it appears that getCanonicalPath deals with varying case-sensitivity
across the directory tree correctly - i'm on a Mac, which has a
case-insensitive HFS+ filesystem [1], and have a linux box mounted over
sftp, which has a case-sensitive filesystem of some sort. If i have a
foo.txt on both, getCanonicalPath correctly maps foo.TXT to foo.txt on the
Mac filesystem, and keeps it as foo.TXT on the linux.
It doesn't on Linux with VFAT filesystems. They remain resolutely
case-sensitive as far as File is concerned:
File.getCanonicalPath("/some/vfatpath/foo.txt") returns /some/vfatpath/foo.txt
File.getCanonicalPath("/some/vfatpath/FOO.txt") returns /some/vfatpath/FOO.txt
Interesting. But that's clearly a bug with linux, not java!![]()
There is nothing wrong with Linux.
A highly debatable statement!
Outside of Java FOO.txt and foo.txt on a VFAT filesystem are the same
file. If you ask for the canonical path to foo.txt you get back foo.txt,
which is a perfectly valid path. If you ask for the path to FOO.txt you
get back FOO.txt which is also a perfectly valid path to the same file.
Both alternatives are valid, but they can't both be canonical (that's what
canonical means), and since getCanonicalPath is called getCanonicalPath, i
would expect it to return a name that is in some way canonical.
But, as i explain in my response to Lew, that only happens when the file
in question exists.
I see no justification for expecting to get back foo.txt when you ask
for FOO.txt. Why foo.txt and not, for example, Foo.txt or fOO.txt or
FOO.TXT all of which are equally valid responses? Why do you expect to
the lowercase filename to be returned?
I don't. I expect to get back the given name of the file referred to by
the path - if such a file exists. If it doesn't, i'm happy to get back a
path with the same capitaisation of the input.
tom