Niklas Gustavsson wrote:
On Fri, Feb 27, 2009 at 1:36 PM, Emmanuel Lecharny <[email protected]> wrote:
Given a file name which might not be in the correct casing, is there a
way to detect the "real" casing in HSF+? For example, what would the
following return?
new File("FOO").getName()
new File("FOO").getAbsolutePath()
new File("FOO").getCanonicalPath()
new File("FOO").getPath()

The name is kept. You will have FOO for all those guys.

Sucks. This is true also if "foo" exists right?
yep.
Now, to detect if the underlying FS is case insensitive, I found that doing
something like :

File f1 = new File( "test" );
File f2 = new File( "TEST" );

if ( !f1.equals( f2 ) ) {
  if ( f1.createNewFile() != f2.createNewFile() ) {
    // Case insensitive but name preserving
  } else {
    // case sensitive
  }
} else {
 // case insensitive
}

Since different directories might come from different file systems,
with different case handling, we would have to do this for each call
to equals (and potentially other methods where this matters). And, as
Ashish points out, we might be in a read-only directory.
Yeah, that would suck...
 I'm not
really happy with this but I can't figure out a better way, besides
someone fixing the JVM.
Btw, it's fixed in Java 6 on Mac OSX, AFAICT. The biggest issue is that you can't run this JVM on OS X 10.4.

Mac is not as cool as it seems to be. Not only their keybord and mouse sucks, but their Java policy stinks like a dead fish... IMHO, of course :)

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to