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, ...@@ -903,8 +903,16 @@ static int DRIVE_GetFreeSpace( int drive, PULARGE_INTEGER size,
#endif #endif
size->s.LowPart = (DWORD)bigsize; size->s.LowPart = (DWORD)bigsize;
size->s.HighPart = (DWORD)(bigsize>>32); size->s.HighPart = (DWORD)(bigsize>>32);
available->s.LowPart = (DWORD)bigavail; if (DRIVE_GetType(drive) == TYPE_CDROM)
available->s.HighPart = (DWORD)(bigavail>>32); { /* 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; return 1;
} }
...@@ -973,7 +981,7 @@ BOOL WINAPI GetDiskFreeSpaceA( LPCSTR root, LPDWORD cluster_sectors, ...@@ -973,7 +981,7 @@ BOOL WINAPI GetDiskFreeSpaceA( LPCSTR root, LPDWORD cluster_sectors,
LPDWORD sector_bytes, LPDWORD free_clusters, LPDWORD sector_bytes, LPDWORD free_clusters,
LPDWORD total_clusters ) LPDWORD total_clusters )
{ {
int drive; int drive, sec_size;
ULARGE_INTEGER size,available; ULARGE_INTEGER size,available;
LPCSTR path; LPCSTR path;
DWORD cluster_sec; DWORD cluster_sec;
...@@ -1000,32 +1008,26 @@ BOOL WINAPI GetDiskFreeSpaceA( LPCSTR root, LPDWORD cluster_sectors, ...@@ -1000,32 +1008,26 @@ BOOL WINAPI GetDiskFreeSpaceA( LPCSTR root, LPDWORD cluster_sectors,
/* Cap the size and available at 2GB as per specs. */ /* Cap the size and available at 2GB as per specs. */
if ((size.s.HighPart) ||(size.s.LowPart > 0x7fffffff)) if ((size.s.HighPart) ||(size.s.LowPart > 0x7fffffff))
{ {
size.s.HighPart = 0; size.s.HighPart = 0;
size.s.LowPart = 0x7fffffff; size.s.LowPart = 0x7fffffff;
} }
if ((available.s.HighPart) ||(available.s.LowPart > 0x7fffffff)) if ((available.s.HighPart) ||(available.s.LowPart > 0x7fffffff))
{ {
available.s.HighPart =0; available.s.HighPart =0;
available.s.LowPart = 0x7fffffff; 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 */ /* fixme: probably have to adjust those variables too for CDFS */
cluster_sec = 1; cluster_sec = 1;
while (cluster_sec * 65536 < size.s.LowPart) cluster_sec *= 2; while (cluster_sec * 65536 < size.s.LowPart) cluster_sec *= 2;
if (cluster_sectors) if (cluster_sectors)
*cluster_sectors = cluster_sec; *cluster_sectors = cluster_sec;
if (sector_bytes)
*sector_bytes = sec_size;
if (free_clusters) if (free_clusters)
*free_clusters = available.s.LowPart / cluster_sec; *free_clusters = available.s.LowPart / cluster_sec;
if (total_clusters) 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