summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/imagedev/cdromimg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/imagedev/cdromimg.cpp')
-rw-r--r--src/devices/imagedev/cdromimg.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/devices/imagedev/cdromimg.cpp b/src/devices/imagedev/cdromimg.cpp
index 5848eb349dc..b4deb9fc4ad 100644
--- a/src/devices/imagedev/cdromimg.cpp
+++ b/src/devices/imagedev/cdromimg.cpp
@@ -79,9 +79,9 @@ void cdrom_image_device::setup_current_preset_image()
m_dvdrom_handle.reset();
chd_file *chd = current_preset_image_chd();
- if (chd->is_cd() || (m_gd_compat && chd->is_gd()))
+ if (!chd->check_is_cd() || (m_gd_compat && !chd->check_is_gd()))
m_cdrom_handle = std::make_unique<cdrom_file>(chd);
- else if(m_dvd_compat && chd->is_dvd())
+ else if(m_dvd_compat && !chd->check_is_dvd())
m_dvdrom_handle = std::make_unique<dvdrom_file>(chd);
else
fatalerror("chd for region %s is not compatible with the cdrom image device\n", preset_images_list()[current_preset_image_id()]);
@@ -130,15 +130,31 @@ std::pair<std::error_condition, std::string> cdrom_image_device::call_load()
// open the CHD file
if (chd)
{
- if (chd->is_cd() || (m_gd_compat && chd->is_gd()))
- m_cdrom_handle.reset(new cdrom_file(chd));
- else if (m_dvd_compat && chd->is_dvd())
- m_dvdrom_handle.reset(new dvdrom_file(chd));
- else
+ err = chd->check_is_cd();
+ if (err == chd_file::error::METADATA_NOT_FOUND && m_gd_compat)
+ err = chd->check_is_gd();
+ if (!err)
{
- err = image_error::INVALIDIMAGE;
+ m_cdrom_handle.reset(new cdrom_file(chd));
+ return std::make_pair(std::error_condition(), std::string());
+ }
+ if (err != chd_file::error::METADATA_NOT_FOUND)
goto error;
+
+ if (m_dvd_compat)
+ {
+ err = chd->check_is_dvd();
+ if (!err)
+ {
+ m_dvdrom_handle.reset(new dvdrom_file(chd));
+ return std::make_pair(std::error_condition(), std::string());
+ }
+ if (err != chd_file::error::METADATA_NOT_FOUND)
+ goto error;
}
+
+ err = image_error::INVALIDIMAGE;
+ goto error;
}
else
{