nsLocalFileMac work. Added GetFileSizeWithResFork() method for callers that need to account for the total size of a Mac file (GetFileSize() only returns the size of the data fork). r=pinkerton

This commit is contained in:
sdagley%netscape.com 2000-02-04 07:17:36 +00:00
Родитель 1cdb1caed9
Коммит d7e10a167b
3 изменённых файлов: 36 добавлений и 0 удалений

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

@ -73,6 +73,11 @@ public:
// SetFileTypeAndCreator call will preserve the existing code
NS_IMETHOD GetFileTypeAndCreator(OSType *type, OSType *creator) = 0;
NS_IMETHOD SetFileTypeAndCreator(OSType type, OSType creator) = 0;
// Since Mac files can consist of both a data and resource fork we have a
// method that will return the combined size of both forks rather than just the
// size of the data fork as returned by GetFileSize()
NS_IMETHOD GetFileSizeWithResFork(PRInt64 *aFileSize) = 0;
};
#endif

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

@ -1636,6 +1636,35 @@ NS_IMETHODIMP nsLocalFile::SetFileTypeAndCreator(OSType type, OSType creator)
return NS_OK;
}
NS_IMETHODIMP
nsLocalFile::GetFileSizeWithResFork(PRInt64 *aFileSize)
{
NS_ENSURE_ARG(aFileSize);
aFileSize->hi = 0;
aFileSize->lo = 0;
ResolveAndStat(PR_TRUE);
long dataSize = 0;
long resSize = 0;
OSErr err = FSpGetFileSize(&mTargetSpec, &dataSize, &resSize);
if (err != noErr)
return MacErrorMapper(err);
// For now we've only got 32 bits of file size info
PRInt64 dataInt64 = LL_Zero();
PRInt64 resInt64 = LL_Zero();
// Combine the size of the resource and data forks
LL_I2L(resInt64, resSize);
LL_I2L(dataInt64, dataSize);
LL_ADD((*aFileSize), dataInt64, resInt64);
return NS_OK;
}
// Handy dandy utility create routine for something or the other
nsresult

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

@ -70,6 +70,8 @@ public:
NS_IMETHOD GetFileTypeAndCreator(OSType *type, OSType *creator);
NS_IMETHOD SetFileTypeAndCreator(OSType type, OSType creator);
NS_IMETHOD GetFileSizeWithResFork(PRInt64 *aFileSize);
private:
// this is the flag which indicates if I can used cached information about the file