Improve Mac OS X local file equality testing, stop comparing FSRefs. b=490372 r=mstange sr=roc

This commit is contained in:
Josh Aas 2009-04-30 10:08:35 -07:00
Родитель 4f1fae16ad
Коммит db4f825cfb
1 изменённых файлов: 8 добавлений и 36 удалений

Просмотреть файл

@ -77,18 +77,6 @@
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]
@ -1212,7 +1200,7 @@ NS_IMETHODIMP nsLocalFile::Clone(nsIFile **_retval)
NS_IMETHODIMP nsLocalFile::Equals(nsIFile *inFile, PRBool *_retval)
{
return EqualsInternal(inFile, _retval);
return EqualsInternal(inFile, _retval);
}
nsresult
@ -1221,30 +1209,14 @@ nsLocalFile::EqualsInternal(nsISupports* inFile, PRBool *_retval)
NS_ENSURE_ARG_POINTER(_retval);
*_retval = PR_FALSE;
nsCOMPtr<nsILocalFileMac> inMacFile(do_QueryInterface(inFile));
if (!inFile)
return NS_OK;
nsCOMPtr<nsILocalFile> inLocalFile(do_QueryInterface(inFile));
if (!inLocalFile)
return NS_ERROR_FAILURE;
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(inMacFile->GetNativePath(inPath)))
if (NS_FAILED(inLocalFile->GetNativePath(inPath)))
return NS_ERROR_FAILURE;
*_retval = thisPath.Equals(inPath);
@ -2275,7 +2247,7 @@ nsresult nsLocalFile::CFStringReftoUTF8(CFStringRef aInStrRef, nsACString& aOutS
NS_IMETHODIMP
nsLocalFile::Equals(nsIHashable* aOther, PRBool *aResult)
{
return EqualsInternal(aOther, aResult);
return EqualsInternal(aOther, aResult);
}
NS_IMETHODIMP