diimage: allow image devices to skip core fopen() of the image's filename and handle themselves in call_load() [R. Belmont]

This commit is contained in:
R. Belmont 2013-01-12 04:46:30 +00:00
parent aec743cb17
commit 7cd142d28d
2 changed files with 40 additions and 36 deletions

View File

@ -936,47 +936,50 @@ bool device_image_interface::load_internal(const char *path, bool is_create, int
if (m_err) if (m_err)
goto done; goto done;
/* Check if there's a software list defined for this device and use that if we're not creating an image */ if (core_opens_image_file())
if (!filename_has_period && !just_load)
{ {
softload = load_software_part( device().machine().options(), this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name, &m_software_list_name ); /* Check if there's a software list defined for this device and use that if we're not creating an image */
// if we had launched from softlist with a specified part, e.g. "shortname:part" if (!filename_has_period && !just_load)
// we would have recorded the wrong name, so record it again based on software_info
if (m_software_info_ptr && m_full_software_name)
m_err = set_image_filename(m_full_software_name);
m_from_swlist = TRUE;
}
if (is_create || filename_has_period)
{
/* determine open plan */
determine_open_plan(is_create, open_plan);
/* attempt to open the file in various ways */
for (i = 0; !m_file && open_plan[i]; i++)
{ {
/* open the file */ softload = load_software_part( device().machine().options(), this, path, &m_software_info_ptr, &m_software_part_ptr, &m_full_software_name, &m_software_list_name );
m_err = load_image_by_path(open_plan[i], path); // if we had launched from softlist with a specified part, e.g. "shortname:part"
if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND)) // we would have recorded the wrong name, so record it again based on software_info
goto done; if (m_software_info_ptr && m_full_software_name)
m_err = set_image_filename(m_full_software_name);
m_from_swlist = TRUE;
} }
}
/* Copy some image information when we have been loaded through a software list */ if (is_create || filename_has_period)
if ( m_software_info_ptr ) {
{ /* determine open plan */
m_longname = m_software_info_ptr->longname; determine_open_plan(is_create, open_plan);
m_manufacturer = m_software_info_ptr->publisher;
m_year = m_software_info_ptr->year;
//m_playable = m_software_info_ptr->supported;
}
/* did we fail to find the file? */ /* attempt to open the file in various ways */
if (!is_loaded() && !softload) for (i = 0; !m_file && open_plan[i]; i++)
{ {
m_err = IMAGE_ERROR_FILENOTFOUND; /* open the file */
goto done; m_err = load_image_by_path(open_plan[i], path);
if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND))
goto done;
}
}
/* Copy some image information when we have been loaded through a software list */
if ( m_software_info_ptr )
{
m_longname = m_software_info_ptr->longname;
m_manufacturer = m_software_info_ptr->publisher;
m_year = m_software_info_ptr->year;
//m_playable = m_software_info_ptr->supported;
}
/* did we fail to find the file? */
if (!is_loaded() && !softload)
{
m_err = IMAGE_ERROR_FILENOTFOUND;
goto done;
}
} }
/* call device load or create */ /* call device load or create */

View File

@ -154,6 +154,7 @@ public:
virtual void call_display() { } virtual void call_display() { }
virtual void call_display_info() { } virtual void call_display_info() { }
virtual device_image_partialhash_func get_partial_hash() const { return NULL; } virtual device_image_partialhash_func get_partial_hash() const { return NULL; }
virtual bool core_opens_image_file() const { return TRUE; }
virtual iodevice_t image_type() const = 0; virtual iodevice_t image_type() const = 0;
virtual bool is_readable() const = 0; virtual bool is_readable() const = 0;
virtual bool is_writeable() const = 0; virtual bool is_writeable() const = 0;