aboutsummaryrefslogtreecommitdiff
path: root/backends/audiocd
diff options
context:
space:
mode:
authorMatthew Hoops2015-10-01 20:36:01 -0400
committerJohannes Schickel2016-03-13 13:57:09 +0100
commit4a6c7b5c831f6d054033d9ded5cb83e4eb6f8d56 (patch)
tree7b09cb4485e4c098de49462bb8d36a923a2ddc13 /backends/audiocd
parent442f91c622075c026c1c2295d72d7f4b7e06b665 (diff)
downloadscummvm-rg350-4a6c7b5c831f6d054033d9ded5cb83e4eb6f8d56.tar.gz
scummvm-rg350-4a6c7b5c831f6d054033d9ded5cb83e4eb6f8d56.tar.bz2
scummvm-rg350-4a6c7b5c831f6d054033d9ded5cb83e4eb6f8d56.zip
BACKENDS: Add support for opening a CD on Windows by drive
Diffstat (limited to 'backends/audiocd')
-rw-r--r--backends/audiocd/win32/win32-audiocd.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/backends/audiocd/win32/win32-audiocd.cpp b/backends/audiocd/win32/win32-audiocd.cpp
index 6dd2b756a9..5de7c7b2e6 100644
--- a/backends/audiocd/win32/win32-audiocd.cpp
+++ b/backends/audiocd/win32/win32-audiocd.cpp
@@ -267,6 +267,9 @@ public:
void closeCD();
void playCD(int track, int numLoops, int startFrame, int duration);
+protected:
+ bool openCD(const Common::String &drive);
+
private:
bool loadTOC();
@@ -314,6 +317,37 @@ bool Win32AudioCDManager::openCD(int drive) {
return false;
}
+bool Win32AudioCDManager::openCD(const Common::String &drive) {
+ // Just some bounds checking
+ if (drive.empty() || drive.size() > 3)
+ return false;
+
+ if (!Common::isAlpha(drive[0]) || drive[1] != ':')
+ return false;
+
+ if (drive[2] != 0 && drive[2] != '\\')
+ return false;
+
+ DriveList drives;
+ if (!tryAddDrive(toupper(drive[0]), drives))
+ return false;
+
+ // Construct the drive path and try to open it
+ Common::String drivePath = Common::String::format("\\\\.\\%c:", drives[0]);
+ _driveHandle = CreateFileA(drivePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
+ if (_driveHandle == INVALID_HANDLE_VALUE) {
+ warning("Failed to open drive %c:\\, error %d", drives[0], (int)GetLastError());
+ return false;
+ }
+
+ if (!loadTOC()) {
+ closeCD();
+ return false;
+ }
+
+ return true;
+}
+
void Win32AudioCDManager::closeCD() {
// Stop any previous track
stop();