Backed out changeset cb8262ea787f
authorJosh Aas <joshmoz@gmail.com>
Thu, 30 Apr 2009 17:01:06 -0700
changeset 27923 9170bcabf752ed142751fd8cffc0995e4716ea30
parent 27921 cb8262ea787fb45fcd644057b42dc61364ade14e
child 27924 ee67b87b2c0e4496c9b9a19f578bf246b4811b70
push id6779
push userjosh@mozilla.com
push dateThu, 30 Apr 2009 23:59:59 +0000
treeherdermozilla-central@ee67b87b2c0e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.2a1pre
backs outcb8262ea787fb45fcd644057b42dc61364ade14e
Backed out changeset cb8262ea787f
xpcom/io/nsLocalFileOSX.mm
--- a/xpcom/io/nsLocalFileOSX.mm
+++ b/xpcom/io/nsLocalFileOSX.mm
@@ -73,16 +73,28 @@
         if (!mBaseURL)                          \
             return NS_ERROR_NOT_INITIALIZED;    \
     PR_END_MACRO
 
 static nsresult MacErrorMapper(OSErr inErr);
 static void CopyUTF8toUTF16NFC(const nsACString& aSrc, nsAString& aResult);
 
 #pragma mark -
+#pragma mark [FSRef operator==]
+
+bool operator==(const FSRef& lhs, const FSRef& rhs)
+{
+  NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
+
+  return (::FSCompareFSRefs(&lhs, &rhs) == noErr);
+
+  NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
+}
+
+#pragma mark -
 #pragma mark [StFollowLinksState]
 
 class StFollowLinksState
 {
   public:
     StFollowLinksState(nsLocalFile& aFile) :
         mFile(aFile)
     {
@@ -1195,36 +1207,52 @@ NS_IMETHODIMP nsLocalFile::Clone(nsIFile
 
     NS_ADDREF(*_retval);
     
     return NS_OK;
 }
 
 NS_IMETHODIMP nsLocalFile::Equals(nsIFile *inFile, PRBool *_retval)
 {
-  return EqualsInternal(inFile, _retval);
+    return EqualsInternal(inFile, _retval);
 }
 
 nsresult
 nsLocalFile::EqualsInternal(nsISupports* inFile, PRBool *_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = PR_FALSE;
-
-  nsCOMPtr<nsILocalFile> inLocalFile(do_QueryInterface(inFile));
-  if (!inLocalFile)
-    return NS_ERROR_FAILURE;
-
+  
+  nsCOMPtr<nsILocalFileMac> inMacFile(do_QueryInterface(inFile));
+  if (!inFile)
+    return NS_OK;
+    
+  nsLocalFile* inLF =
+      static_cast<nsLocalFile*>((nsILocalFileMac*) inMacFile);
+
+  // If both exist, compare FSRefs
+  FSRef thisFSRef, inFSRef;
+  nsresult rv1 = GetFSRefInternal(thisFSRef);
+  nsresult rv2 = inLF->GetFSRefInternal(inFSRef);
+  if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2)) {
+    *_retval = (thisFSRef == inFSRef);
+    return NS_OK;
+  }
+  // If one exists and the other doesn't, not equal  
+  if (rv1 != rv2)
+    return NS_OK;
+    
+  // Arg, we have to get their paths and compare
   nsCAutoString thisPath, inPath;
   if (NS_FAILED(GetNativePath(thisPath)))
     return NS_ERROR_FAILURE;
-  if (NS_FAILED(inLocalFile->GetNativePath(inPath)))
+  if (NS_FAILED(inMacFile->GetNativePath(inPath)))
     return NS_ERROR_FAILURE;
   *_retval = thisPath.Equals(inPath);
-
+  
   return NS_OK;
 }
 
 NS_IMETHODIMP nsLocalFile::Contains(nsIFile *inFile, PRBool recur, PRBool *_retval)
 {
   // Check we are correctly initialized.
   CHECK_mBaseURL();
 
@@ -2242,17 +2270,17 @@ nsresult nsLocalFile::CFStringReftoUTF8(
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 // nsIHashable
 
 NS_IMETHODIMP
 nsLocalFile::Equals(nsIHashable* aOther, PRBool *aResult)
 {
-  return EqualsInternal(aOther, aResult);
+    return EqualsInternal(aOther, aResult);
 }
 
 NS_IMETHODIMP
 nsLocalFile::GetHashCode(PRUint32 *aResult)
 {
     NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
 
     CFStringRef pathStrRef = ::CFURLCopyFileSystemPath(mBaseURL, kCFURLPOSIXPathStyle);