Bug 177059 Mach-0 nsLocalFile::GetFileSize sometimes fails for directories. Patch by sfraser. r=ccarlen/sr=bryner

git-svn-id: svn://10.0.0.236/trunk@133401 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ccarlen%netscape.com
2002-11-08 15:03:06 +00:00
parent 3bc51b679e
commit 152baeb1b3

View File

@@ -766,6 +766,7 @@ NS_IMETHODIMP nsLocalFile::SetLastModifiedTimeOfLink(PRInt64 aLastModifiedTimeOf
NS_IMETHODIMP nsLocalFile::GetFileSize(PRInt64 *aFileSize)
{
NS_ENSURE_ARG_POINTER(aFileSize);
*aFileSize = 0;
FSRef fsRef;
nsresult rv = GetFSRefInternal(fsRef);
@@ -773,12 +774,15 @@ NS_IMETHODIMP nsLocalFile::GetFileSize(PRInt64 *aFileSize)
return rv;
FSCatalogInfo catalogInfo;
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoDataSizes, &catalogInfo,
OSErr err = ::FSGetCatalogInfo(&fsRef, kFSCatInfoNodeFlags + kFSCatInfoDataSizes, &catalogInfo,
nsnull, nsnull, nsnull);
if (err != noErr)
return MacErrorMapper(err);
*aFileSize = catalogInfo.dataLogicalSize;
// FSGetCatalogInfo can return a bogus size for directories sometimes, so only
// rely on the answer for files
if ((catalogInfo.nodeFlags & kFSNodeIsDirectoryMask) == 0)
*aFileSize = catalogInfo.dataLogicalSize;
return NS_OK;
}