Closed
Bug 13204
Opened 25 years ago
Closed 25 years ago
Space available should be a float double or a 64 bit integer
Categories
(Core :: XPCOM, defect, P3)
Tracking
()
M14
People
(Reporter: cmurphy, Assigned: dougt)
Details
Space available should be a float double or a 64 bit integer for nsFileSpec::GetDiskSpaceAvailable(). Returning a 32 bit value will be incorrect for large drives. Also the windows implementation used will return the incorrect results due to integer overflow on line 592 for large drives. This is the function that I currently use on Windows: double CheckDiskSpace(LPCTSTR strRoot) { // Check disk space DWORD dwSecPerClus, dwBytesPerSec, dwFreeClus, dwTotalClus; ULARGE_INTEGER liFreeBytesAvailableToCaller, liTotalNumberOfBytes, liTotalNumberOfFreeBytes; double nBytes = 0; BOOL (WINAPI* getDiskFreeSpaceExA)(LPCTSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailableToCaller, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes) = NULL; HINSTANCE hInst = LoadLibrary(_T("KERNEL32.DLL")); ASSERT(hInst != NULL); if (hInst != NULL) { getDiskFreeSpaceExA = (BOOL (WINAPI*)(LPCTSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailableToCaller, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes)) GetProcAddress(hInst, "GetDiskFreeSpaceExA"); FreeLibrary(hInst); } if (getDiskFreeSpaceExA && (*getDiskFreeSpaceExA)(strRoot, &liFreeBytesAvailableToCaller, &liTotalNumberOfBytes, &liTotalNumberOfFreeBytes)) { nBytes = (double)(signed __int64) liFreeBytesAvailableToCaller.QuadPart; } else if (GetDiskFreeSpace(strRoot, &dwSecPerClus, &dwBytesPerSec, &dwFreeClus, &dwTotalClus)) { nBytes = (double)dwFreeClus*(double)dwSecPerClus*(double) dwBytesPerSec; } return nBytes; } This works on Windows 95/98/2000 and NT4. Chet Murphy Modelworks Software cmurphy@modelworks.com http://www.modelworks.com voice: 425 830 4047 fax: 253 830 7802
Updated•25 years ago
|
Assignee: warren → dougt
Updated•25 years ago
|
Target Milestone: M14
Assignee | ||
Updated•25 years ago
|
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → DUPLICATE
Assignee | ||
Comment 1•25 years ago
|
||
I hope to address this soon. marking as dup. *** This bug has been marked as a duplicate of 12479 ***
Updated•25 years ago
|
Status: RESOLVED → VERIFIED
Comment 2•25 years ago
|
||
Verified duplicate.
Comment 3•25 years ago
|
||
Bulk moving to XPCOM, in preparation for removal of XP File Handling component. (XPFH has received two bugs in ~5 months, and is no longer in active use.)
Component: XP File Handling → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•