mirror of
https://github.com/holub/mame
synced 2025-07-04 17:38:08 +03:00
-imagedev/harddriv.cpp: Report unsuitable CHDs rather than crashing.
-imagedev/cdrom.cpp: Report unsuitable CHDs as "invalid image" rather than "unsupported operation".
This commit is contained in:
parent
85c9517c69
commit
a17ea8387c
@ -136,7 +136,7 @@ std::pair<std::error_condition, std::string> cdrom_image_device::call_load()
|
|||||||
m_dvdrom_handle.reset(new dvdrom_file(chd));
|
m_dvdrom_handle.reset(new dvdrom_file(chd));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = image_error::UNSUPPORTED;
|
err = image_error::INVALIDIMAGE;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,15 +146,15 @@ std::pair<std::error_condition, std::string> cdrom_image_device::call_load()
|
|||||||
{
|
{
|
||||||
m_cdrom_handle.reset(new cdrom_file(filename()));
|
m_cdrom_handle.reset(new cdrom_file(filename()));
|
||||||
}
|
}
|
||||||
catch (void *)
|
catch (...)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_dvdrom_handle.reset(new dvdrom_file(filename()));
|
m_dvdrom_handle.reset(new dvdrom_file(filename()));
|
||||||
}
|
}
|
||||||
catch (void *)
|
catch (...)
|
||||||
{
|
{
|
||||||
err = image_error::UNSUPPORTED;
|
err = image_error::INVALIDIMAGE;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,24 +287,31 @@ std::error_condition harddisk_image_device::internal_load_hd()
|
|||||||
if (m_chd)
|
if (m_chd)
|
||||||
{
|
{
|
||||||
// open the hard disk file
|
// open the hard disk file
|
||||||
|
try
|
||||||
|
{
|
||||||
m_hard_disk_handle.reset(new hard_disk_file(m_chd));
|
m_hard_disk_handle.reset(new hard_disk_file(m_chd));
|
||||||
if (m_hard_disk_handle)
|
if (m_hard_disk_handle)
|
||||||
return std::error_condition();
|
return std::error_condition();
|
||||||
}
|
}
|
||||||
else
|
catch (...)
|
||||||
{
|
{
|
||||||
if (is_open())
|
err = image_error::INVALIDIMAGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!is_open())
|
||||||
|
{
|
||||||
|
err = image_error::UNSPECIFIED;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
uint32_t skip = 0;
|
uint32_t skip = 0;
|
||||||
|
|
||||||
// check for 2MG format
|
if (!memcmp(header, "2IMG", 4)) // check for 2MG format
|
||||||
if (!memcmp(header, "2IMG", 4))
|
|
||||||
{
|
{
|
||||||
skip = get_u32le(&header[0x18]);
|
skip = get_u32le(&header[0x18]);
|
||||||
osd_printf_verbose("harddriv: detected 2MG, creator is %c%c%c%c, data at %08x\n", header[4], header[5], header[6], header[7], skip);
|
osd_printf_verbose("harddriv: detected 2MG, creator is %c%c%c%c, data at %08x\n", header[4], header[5], header[6], header[7], skip);
|
||||||
}
|
}
|
||||||
// check for HDI format
|
else if (is_filetype("hdi")) // check for HDI format
|
||||||
else if (is_filetype("hdi"))
|
|
||||||
{
|
{
|
||||||
skip = get_u32le(&header[0x8]);
|
skip = get_u32le(&header[0x8]);
|
||||||
uint32_t data_size = get_u32le(&header[0xc]);
|
uint32_t data_size = get_u32le(&header[0xc]);
|
||||||
@ -318,17 +325,21 @@ std::error_condition harddisk_image_device::internal_load_hd()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
m_hard_disk_handle.reset(new hard_disk_file(image_core_file(), skip));
|
m_hard_disk_handle.reset(new hard_disk_file(image_core_file(), skip));
|
||||||
if (m_hard_disk_handle)
|
if (m_hard_disk_handle)
|
||||||
return std::error_condition();
|
return std::error_condition();
|
||||||
}
|
}
|
||||||
|
catch (...)
|
||||||
return image_error::UNSPECIFIED;
|
{
|
||||||
|
err = image_error::INVALIDIMAGE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we had an error, close out the CHD */
|
/* if we had an error, close out the CHD */
|
||||||
m_origchd.close();
|
|
||||||
m_diffchd.close();
|
m_diffchd.close();
|
||||||
|
m_origchd.close();
|
||||||
m_chd = nullptr;
|
m_chd = nullptr;
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
|
Loading…
Reference in New Issue
Block a user