mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-19 06:40:58 +00:00
Better drive detection - won't return flash drives and stuff anymore, just disc drives, real + virtual.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2371 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
8224c3b449
commit
3dfac4fcc8
@ -15,6 +15,8 @@
|
|||||||
// Official SVN repository and contact information can be found at
|
// Official SVN repository and contact information can be found at
|
||||||
// http://code.google.com/p/dolphin-emu/
|
// http://code.google.com/p/dolphin-emu/
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
#include "DriveUtil.h"
|
#include "DriveUtil.h"
|
||||||
|
|
||||||
@ -26,29 +28,18 @@
|
|||||||
void GetAllRemovableDrives(std::vector<std::string> *drives) {
|
void GetAllRemovableDrives(std::vector<std::string> *drives) {
|
||||||
drives->clear();
|
drives->clear();
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HANDLE hDisk;
|
char drives_string[1024];
|
||||||
DISK_GEOMETRY diskGeometry;
|
int max_drive_pos = GetLogicalDriveStrings(1024, drives_string);
|
||||||
|
char *p = drives_string;
|
||||||
for (int i = 'D'; i < 'Z'; i++)
|
// GetLogicalDriveStrings returns the drives as a a series of null-terminated strings
|
||||||
|
// laid out right after each other in RAM, with a double null at the end.
|
||||||
|
while (*p)
|
||||||
{
|
{
|
||||||
char path[MAX_PATH];
|
if (GetDriveType(p) == DRIVE_CDROM) // CD_ROM also applies to DVD. Noone has a plain CDROM without DVD anymore so we should be fine.
|
||||||
sprintf(path, "\\\\.\\%c:", i);
|
|
||||||
hDisk = CreateFile(path, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
|
|
||||||
if (hDisk != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
{
|
||||||
DWORD dwBytes;
|
drives->push_back(std::string(p).substr(0, 2));
|
||||||
DeviceIoControl(hDisk, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &diskGeometry, sizeof(DISK_GEOMETRY), &dwBytes, NULL);
|
|
||||||
// Only proceed if disk is a removable media
|
|
||||||
if (diskGeometry.MediaType == RemovableMedia)
|
|
||||||
{
|
|
||||||
if (diskGeometry.BytesPerSector == 2048) {
|
|
||||||
// Probably CD/DVD drive.
|
|
||||||
// "Remove" the "\\.\" part of the path and return it.
|
|
||||||
drives->push_back(path + 4);
|
|
||||||
}
|
}
|
||||||
}
|
p += strlen(p) + 1;
|
||||||
}
|
|
||||||
CloseHandle(hDisk);
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// TODO
|
// TODO
|
||||||
|
Loading…
x
Reference in New Issue
Block a user