mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[FORMAT] Use QueryDeviceInformation for retrieving the volume size before formatting it
QueryDeviceInformation returns more reliable volume length and works with unformatted volumes. It will return volume length only on ROS and Vista+ however, so also keep the GetFreeDiskSpaceExW as a fallback for XP/2003.
This commit is contained in:
parent
4838d7bd56
commit
c5a9f22d4e
1 changed files with 14 additions and 1 deletions
|
@ -360,6 +360,7 @@ static VOID Usage(LPWSTR ProgramName)
|
|||
int wmain(int argc, WCHAR *argv[])
|
||||
{
|
||||
int badArg;
|
||||
DEVICE_INFORMATION DeviceInformation = {0};
|
||||
FMIFS_MEDIA_FLAG media = FMIFS_HARDDISK;
|
||||
DWORD driveType;
|
||||
WCHAR fileSystem[1024];
|
||||
|
@ -479,7 +480,19 @@ int wmain(int argc, WCHAR *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!GetDiskFreeSpaceExW(RootDirectory,
|
||||
if (QueryDeviceInformation(RootDirectory,
|
||||
&DeviceInformation,
|
||||
sizeof(DeviceInformation)))
|
||||
{
|
||||
totalNumberOfBytes.QuadPart = DeviceInformation.SectorSize *
|
||||
DeviceInformation.SectorCount.QuadPart;
|
||||
}
|
||||
|
||||
/* QueryDeviceInformation returns more accurate volume length and works with
|
||||
* unformatted volumes, however it will NOT return volume length on XP/2003.
|
||||
* Fallback to GetFreeDiskSpaceExW if we did not get any volume length. */
|
||||
if (totalNumberOfBytes.QuadPart == 0 &&
|
||||
!GetDiskFreeSpaceExW(RootDirectory,
|
||||
&freeBytesAvailableToCaller,
|
||||
&totalNumberOfBytes,
|
||||
&totalNumberOfFreeBytes))
|
||||
|
|
Loading…
Reference in a new issue