diff --git a/src/dos/cdrom.cpp b/src/dos/cdrom.cpp index d3694d7e..7b46db85 100644 --- a/src/dos/cdrom.cpp +++ b/src/dos/cdrom.cpp @@ -22,17 +22,14 @@ #include #include -#include "dosbox.h" #include "support.h" -int CDROM_GetMountType(char* path) { -// 1 - Iso file -// 2 - subdirectory - - // Detect ISO +MountType CDROM_GetMountType(const char *path) { struct stat file_stat; - if ((stat(path, &file_stat) == 0) && (file_stat.st_mode & S_IFREG)) return 1; - return 2; + if ((stat(path, &file_stat) == 0) && (file_stat.st_mode & S_IFREG)) + return MountType::ISO_IMAGE; + else + return MountType::DIRECTORY; } // ****************************************************** @@ -73,5 +70,3 @@ bool CDROM_Interface_Fake :: GetMediaTrayStatus(bool& mediaPresent, bool& mediaC trayOpen = false; return true; } - - diff --git a/src/dos/cdrom.h b/src/dos/cdrom.h index c9735018..3f02f6b8 100644 --- a/src/dos/cdrom.h +++ b/src/dos/cdrom.h @@ -56,6 +56,12 @@ typedef struct SCtrl { Bit8u vol[4]; // channel volume (0 to 255) } TCtrl; +enum class MountType { + PHYSICAL_CD, + ISO_IMAGE, + DIRECTORY, +}; + // Conversion function from frames to Minutes/Second/Frames // template @@ -73,7 +79,7 @@ inline int msf_to_frames(int m, int s, int f) { return m * 60 * REDBOOK_FRAMES_PER_SECOND + s * REDBOOK_FRAMES_PER_SECOND + f; } -extern int CDROM_GetMountType(char* path); +MountType CDROM_GetMountType(const char *path); class CDROM_Interface { diff --git a/src/dos/dos_mscdex.cpp b/src/dos/dos_mscdex.cpp index 3a060bfe..ee26ad60 100644 --- a/src/dos/dos_mscdex.cpp +++ b/src/dos/dos_mscdex.cpp @@ -249,23 +249,21 @@ int CMscdex::AddDrive(Bit16u _drive, char* physicalPath, Bit8u& subUnit) int result = 0; // Get Mounttype and init needed cdrom interface switch (CDROM_GetMountType(physicalPath)) { - case 0x00: - LOG(LOG_MISC,LOG_NORMAL)("MSCDEX: Mounting physical cdrom: %s" ,physicalPath); + case MountType::PHYSICAL_CD: + LOG(LOG_MISC,LOG_NORMAL)("MSCDEX: Mounting physical cdrom: %s", physicalPath); // TODO: support for mounting physical CD-ROMs removed, provide // warnings/explanations for users return 2; - case 0x01: // iso cdrom interface + case MountType::ISO_IMAGE: LOG(LOG_MISC,LOG_NORMAL)("MSCDEX: Mounting iso file as cdrom: %s", physicalPath); cdrom[numDrives] = new CDROM_Interface_Image((Bit8u)numDrives); break; - case 0x02: // fake cdrom interface (directories) + case MountType::DIRECTORY: cdrom[numDrives] = new CDROM_Interface_Fake; LOG(LOG_MISC,LOG_NORMAL)("MSCDEX: Mounting directory as cdrom: %s",physicalPath); LOG(LOG_MISC,LOG_NORMAL)("MSCDEX: You wont have full MSCDEX support !"); result = 5; break; - default : // weird result - return 6; }; if (!cdrom[numDrives]->SetDevice(physicalPath)) {