Commit 551ef365 authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

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.
parent 4a38fb2b
......@@ -114,10 +114,27 @@ static void test_GetDiskFreeSpaceA(void)
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
drive, ret, GetLastError());
else
{
ok(ret ||
(!ret && (GetLastError() == ERROR_NOT_READY || GetLastError() == ERROR_INVALID_DRIVE)),
"GetDiskFreeSpaceA(%s): ret=%d GetLastError=%ld\n",
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;
}
......
......@@ -1333,11 +1333,20 @@ BOOL WINAPI GetDiskFreeSpaceW( LPCWSTR root, LPDWORD cluster_sectors,
units = info.SectorsPerAllocationUnit * info.BytesPerSector;
/* cap the size and available at 2GB as per specs */
if (info.AvailableAllocationUnits.QuadPart * units > 0x7fffffff)
info.AvailableAllocationUnits.QuadPart = 0x7fffffff / units;
if (info.TotalAllocationUnits.QuadPart * units > 0x7fffffff)
info.TotalAllocationUnits.QuadPart = 0x7fffffff / units;
if( GetVersion() & 0x80000000) { /* win3.x, 9x, ME */
/* cap the size and available at 2GB as per specs */
if (info.TotalAllocationUnits.QuadPart * units > 0x7fffffff) {
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 (sector_bytes) *sector_bytes = info.BytesPerSector;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment