On Fri, Feb 27, 2009 at 1:36 PM, Emmanuel Lecharny <elecha...@apache.org> 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? > 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. I'm not really happy with this but I can't figure out a better way, besides someone fixing the JVM. Not that that is very likely of course. There is an interesting discussion on this topic over here http://lists.apple.com/archives/java-dev/2004/Feb/msg00331.html but it merely makes to whole thing more complex, rather than find any solutions. They also refers to a bug reported to Apple, but I always fail to access their bug management tool so I haven't checked it out. /niklas