cdvd:windows: Fix disc path

The disc path was not always in the correct format.

Fixes a regression from the CDVD merge.
This commit is contained in:
Jonathan Li 2021-06-06 18:02:26 +01:00
parent 33d8290fd4
commit 7f8ca17752
2 changed files with 15 additions and 17 deletions

View File

@ -189,6 +189,8 @@ s32 CALLBACK DISCopen(const char* pTitle)
std::string drive = g_Conf->Folders.RunDisc.GetPath().ToStdString(); std::string drive = g_Conf->Folders.RunDisc.GetPath().ToStdString();
#endif #endif
GetValidDrive(drive); GetValidDrive(drive);
if (drive.empty())
return -1;
// open device file // open device file
try try

View File

@ -41,15 +41,12 @@ void GetValidDrive(std::wstring& drive)
auto drives = GetOpticalDriveList(); auto drives = GetOpticalDriveList();
if (drives.empty()) if (drives.empty())
{ {
drive = {}; drive.clear();
return;
} }
else
{
drive = drives.front(); drive = drives.front();
} }
}
else
{
int size = WideCharToMultiByte(CP_UTF8, 0, drive.c_str(), -1, nullptr, 0, nullptr, nullptr); int size = WideCharToMultiByte(CP_UTF8, 0, drive.c_str(), -1, nullptr, 0, nullptr, nullptr);
std::vector<char> converted_string(size); std::vector<char> converted_string(size);
WideCharToMultiByte(CP_UTF8, 0, drive.c_str(), -1, converted_string.data(), converted_string.size(), nullptr, nullptr); WideCharToMultiByte(CP_UTF8, 0, drive.c_str(), -1, converted_string.data(), converted_string.size(), nullptr, nullptr);
@ -60,4 +57,3 @@ void GetValidDrive(std::wstring& drive)
drive.pop_back(); drive.pop_back();
drive.insert(0, L"\\\\.\\"); drive.insert(0, L"\\\\.\\");
} }
}