Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: How is file equality/existenced one in OSX
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How is file equality/existenced one in OSX



On Nov 29, 2010, at 8:55 AM, Paul Taylor wrote:

> On OSX it seems that if a file is compared with another file ( file1.equals(file2) ) it will mark them as different if they just change in case but when checking if a file exists (file1.exists()) it ignores case. It this correct, if so Im finding it counter-intuitive

As Sandro said, File.exists() calls down to the OS to see if the file exists. File.equals() does just does a string compare in java code. We have a really old bug on this <rdar://2844196> and so does Sun/Oracle - <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4787260>. Its probably a bigger deal on MacOSX since the filesystem is case insensitive by default.

The workaround is to use getCanonicalFile()/getCanonicalPath() and then compare those.

Pratik _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >How is file equality/existenced one in OSX (From: Paul Taylor <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.