summaryrefslogtreecommitdiffstats
path: root/src/devices/imagedev/chd_cd.cpp
diff options
context:
space:
mode:
author Vas Crabb <cuavas@users.noreply.github.com>2021-08-22 09:06:15 +1000
committer GitHub <noreply@github.com>2021-08-22 09:06:15 +1000
commite8bbea1fc6e94e14768509d322f6c624403ffb36 (patch)
tree74dd1606a900d83de8aecff17a6737af4113308d /src/devices/imagedev/chd_cd.cpp
parente319bde5fc3696d7f48f62b15b6366c4377fe5d1 (diff)
formats, osd, util: Started refactoring file I/O stuff. (#8456)
Added more modern generic I/O interfaces with implementation backed by stdio, osd_file and core_file, replacing io_generic. Also replaced core_file's build-in zlib compression with a filter. unzip.cpp, un7z.cpp: Added option to supply abstract I/O interface rather than filename. Converted osd_file, core_file, archive_file, chd_file and device_image_interface to use std::error_condition rather than their own error enums. Allow mounting TI-99 RPK from inside archives.
Diffstat (limited to 'src/devices/imagedev/chd_cd.cpp')
-rw-r--r--src/devices/imagedev/chd_cd.cpp23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/devices/imagedev/chd_cd.cpp b/src/devices/imagedev/chd_cd.cpp
index 5daaba2ed45..4eacb3d3b58 100644
--- a/src/devices/imagedev/chd_cd.cpp
+++ b/src/devices/imagedev/chd_cd.cpp
@@ -83,17 +83,16 @@ void cdrom_image_device::device_stop()
image_init_result cdrom_image_device::call_load()
{
- chd_error err = (chd_error)0;
- chd_file *chd = nullptr;
+ std::error_condition err;
+ chd_file *chd = nullptr;
if (m_cdrom_handle)
cdrom_close(m_cdrom_handle);
- if (!loaded_through_softlist())
- {
+ if (!loaded_through_softlist()) {
if (is_filetype("chd") && is_loaded()) {
- err = m_self_chd.open( image_core_file() ); /* CDs are never writeable */
- if ( err )
+ err = m_self_chd.open(util::core_file_read_write(image_core_file())); // CDs are never writeable
+ if (err)
goto error;
chd = &m_self_chd;
}
@@ -103,20 +102,20 @@ image_init_result cdrom_image_device::call_load()
/* open the CHD file */
if (chd) {
- m_cdrom_handle = cdrom_open( chd );
+ m_cdrom_handle = cdrom_open(chd);
} else {
m_cdrom_handle = cdrom_open(filename());
}
- if ( ! m_cdrom_handle )
+ if (!m_cdrom_handle)
goto error;
return image_init_result::PASS;
error:
- if ( chd && chd == &m_self_chd )
- m_self_chd.close( );
- if ( err )
- seterror( IMAGE_ERROR_UNSPECIFIED, chd_file::error_string( err ) );
+ if (chd && chd == &m_self_chd)
+ m_self_chd.close();
+ if (err)
+ seterror(err, nullptr);
return image_init_result::FAIL;
}