Commit bd86d18f authored by Andreas Mohr's avatar Andreas Mohr Committed by Alexandre Julliard

DRIVE_GetFreeSpace() is supposed to *always* return 0 for "avail"

on CD-ROMs, even if CD-ROM is *not* mounted and thus the mount point normally returns the "avail" of the corresponding partition. Cleaned up GetDiskFreeSpaceA.
parent e908fd38
......@@ -903,8 +903,16 @@ static int DRIVE_GetFreeSpace( int drive, PULARGE_INTEGER size,
#endif
size->s.LowPart = (DWORD)bigsize;
size->s.HighPart = (DWORD)(bigsize>>32);
if (DRIVE_GetType(drive) == TYPE_CDROM)
{ /* ALWAYS 0, even if no real CD-ROM mounted there !! */
available->s.LowPart = 0;
available->s.HighPart = 0;
}
else
{
available->s.LowPart = (DWORD)bigavail;
available->s.HighPart = (DWORD)(bigavail>>32);
}
return 1;
}
......@@ -973,7 +981,7 @@ BOOL WINAPI GetDiskFreeSpaceA( LPCSTR root, LPDWORD cluster_sectors,
LPDWORD sector_bytes, LPDWORD free_clusters,
LPDWORD total_clusters )
{
int drive;
int drive, sec_size;
ULARGE_INTEGER size,available;
LPCSTR path;
DWORD cluster_sec;
......@@ -1009,23 +1017,17 @@ BOOL WINAPI GetDiskFreeSpaceA( LPCSTR root, LPDWORD cluster_sectors,
available.s.HighPart =0;
available.s.LowPart = 0x7fffffff;
}
if (DRIVE_GetType(drive)==TYPE_CDROM) {
if (sector_bytes)
*sector_bytes = 2048;
size.s.LowPart /= 2048;
available.s.LowPart /= 2048;
} else {
if (sector_bytes)
*sector_bytes = 512;
size.s.LowPart /= 512;
available.s.LowPart /= 512;
}
sec_size = (DRIVE_GetType(drive)==TYPE_CDROM) ? 2048 : 512;
size.s.LowPart /= sec_size;
available.s.LowPart /= sec_size;
/* fixme: probably have to adjust those variables too for CDFS */
cluster_sec = 1;
while (cluster_sec * 65536 < size.s.LowPart) cluster_sec *= 2;
if (cluster_sectors)
*cluster_sectors = cluster_sec;
if (sector_bytes)
*sector_bytes = sec_size;
if (free_clusters)
*free_clusters = available.s.LowPart / cluster_sec;
if (total_clusters)
......
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