In GetDiskFreeSpace:
- only cap the total size and available size to 2GB in Win3.x thru WinME; - in that case adjust number of clusters to be less then 65536 by increasing the cluster size; - add corresponding tests.
This commit is contained in:
parent
4a38fb2b10
commit
551ef36517
|
@ -114,10 +114,27 @@ static void test_GetDiskFreeSpaceA(void)
|
||||||
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
|
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
|
||||||
drive, ret, GetLastError());
|
drive, ret, GetLastError());
|
||||||
else
|
else
|
||||||
|
{
|
||||||
ok(ret ||
|
ok(ret ||
|
||||||
(!ret && (GetLastError() == ERROR_NOT_READY || GetLastError() == ERROR_INVALID_DRIVE)),
|
(!ret && (GetLastError() == ERROR_NOT_READY || GetLastError() == ERROR_INVALID_DRIVE)),
|
||||||
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
|
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
|
||||||
drive, ret, GetLastError());
|
drive, ret, GetLastError());
|
||||||
|
if( GetVersion() & 0x80000000)
|
||||||
|
/* win3.0 thru winME */
|
||||||
|
ok( total_clusters <= 65535,
|
||||||
|
"total clusters is %ld > 65535\n", total_clusters);
|
||||||
|
else {
|
||||||
|
/* NT, 2k, XP : GetDiskFreeSpace shoud be accurate */
|
||||||
|
ULARGE_INTEGER totEx, tot, d;
|
||||||
|
tot.QuadPart = sectors_per_cluster;
|
||||||
|
tot.QuadPart = (tot.QuadPart * bytes_per_sector) * total_clusters;
|
||||||
|
ret = GetDiskFreeSpaceExA( drive, &d, &totEx, NULL);
|
||||||
|
ok( ret, "GetDiskFreeSpaceExA( %s ) failed. GetLastError=%ld\n", drive, GetLastError());
|
||||||
|
ok( bytes_per_sector == 0 || /* empty cd rom drive */
|
||||||
|
totEx.QuadPart <= tot.QuadPart,
|
||||||
|
"GetDiskFreeSpaceA should report at least as much bytes on disk %s as GetDiskFreeSpaceExA\n", drive);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
logical_drives >>= 1;
|
logical_drives >>= 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1333,11 +1333,20 @@ BOOL WINAPI GetDiskFreeSpaceW( LPCWSTR root, LPDWORD cluster_sectors,
|
||||||
|
|
||||||
units = info.SectorsPerAllocationUnit * info.BytesPerSector;
|
units = info.SectorsPerAllocationUnit * info.BytesPerSector;
|
||||||
|
|
||||||
/* cap the size and available at 2GB as per specs */
|
if( GetVersion() & 0x80000000) { /* win3.x, 9x, ME */
|
||||||
if (info.AvailableAllocationUnits.QuadPart * units > 0x7fffffff)
|
/* cap the size and available at 2GB as per specs */
|
||||||
info.AvailableAllocationUnits.QuadPart = 0x7fffffff / units;
|
if (info.TotalAllocationUnits.QuadPart * units > 0x7fffffff) {
|
||||||
if (info.TotalAllocationUnits.QuadPart * units > 0x7fffffff)
|
info.TotalAllocationUnits.QuadPart = 0x7fffffff / units;
|
||||||
info.TotalAllocationUnits.QuadPart = 0x7fffffff / units;
|
if (info.AvailableAllocationUnits.QuadPart * units > 0x7fffffff)
|
||||||
|
info.AvailableAllocationUnits.QuadPart = 0x7fffffff / units;
|
||||||
|
}
|
||||||
|
/* nr. of clusters is always <= 65335 */
|
||||||
|
while( info.TotalAllocationUnits.QuadPart > 65535 ) {
|
||||||
|
info.TotalAllocationUnits.QuadPart /= 2;
|
||||||
|
info.AvailableAllocationUnits.QuadPart /= 2;
|
||||||
|
info.SectorsPerAllocationUnit *= 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cluster_sectors) *cluster_sectors = info.SectorsPerAllocationUnit;
|
if (cluster_sectors) *cluster_sectors = info.SectorsPerAllocationUnit;
|
||||||
if (sector_bytes) *sector_bytes = info.BytesPerSector;
|
if (sector_bytes) *sector_bytes = info.BytesPerSector;
|
||||||
|
|
Loading…
Reference in New Issue