1
0
Fork 0

Introduce MountType enum for CDROM_GetMountType

This commit is contained in:
Patryk Obara 2019-12-02 11:35:29 +01:00 committed by Patryk Obara
parent f82a0a46da
commit 28dd59e03e
3 changed files with 16 additions and 17 deletions

View file

@ -22,17 +22,14 @@
#include <sys/stat.h>
#include <unistd.h>
#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;
}

View file

@ -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<typename T>
@ -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
{

View file

@ -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)) {