diff options
author | 2024-10-11 20:58:12 -0400 | |
---|---|---|
committer | 2024-10-11 21:05:51 -0400 | |
commit | beb81e484240c450932cd95e70fdfb6559f01eb2 (patch) | |
tree | 7fe0295911a217a2cf9280bcd00357fd3addbda7 /src/devices/imagedev/cdromimg.cpp | |
parent | a06ca9e7226b5152f3189d8bd9ae96d3de68dcee (diff) |
chd.cpp: More API changes
- Have metadata_find return std::error_condition instead of throwing an exception
- Replace the is_XXX predicates with check_is_XXX methods that return a std::error_condition, enabling improved error reporting for cdrom_image_device
- Retain read error information in chd_file_compressor
- Make a bunch of methods noexcept
This mostly restores the changes from cc772072fa635146b1df39a5694d2a8f8aa5a34f.
Diffstat (limited to 'src/devices/imagedev/cdromimg.cpp')
-rw-r--r-- | src/devices/imagedev/cdromimg.cpp | 32 |
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 { |