[core] detect memory cards in card readers

* Also remove drives with no media from the list
* Closes #18
This commit is contained in:
Pete Batard 2013-12-20 18:32:10 +00:00
parent 897becd290
commit 36693d2144
6 changed files with 75 additions and 9 deletions

View file

@ -450,6 +450,23 @@ uint64_t GetDriveSize(DWORD DriveIndex)
return DiskGeometry->DiskSize.QuadPart;
}
/*
* GET_DRIVE_GEOMETRY is used to tell if there is an actual media
*/
BOOL IsMediaPresent(DWORD DriveIndex)
{
BOOL r;
HANDLE hPhysical;
DWORD size;
BYTE geometry[128];
hPhysical = GetPhysicalHandle(DriveIndex, FALSE, FALSE);
r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX,
NULL, 0, geometry, sizeof(geometry), &size, NULL) || (size <= 0);
safe_closehandle(hPhysical);
return r;
}
/*
* Fill the drive properties (size, FS, etc)
*/