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

This commit is contained in:
ccarlen%netscape.com 2002-11-08 15:03:06 +00:00
Родитель 47412da3e6
Коммит aee74580af
1 изменённых файлов: 7 добавлений и 3 удалений

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

@ -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,11 +774,14 @@ 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);
// 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;
}