diff options
author | 2017-04-08 20:43:15 -0400 | |
---|---|---|
committer | 2017-04-10 20:47:40 -0400 | |
commit | afa6a83728be7339b7f9e76c719736665af611a2 (patch) | |
tree | b4d5c4abc6a41367736cbd57619165f10eeb4b61 /src/emu/dislot.cpp | |
parent | 5671a5eeab28af55588c0d0e722fd164a89e5f0c (diff) |
Changes to make get_default_card_software() less stupid
The goals with this change is to make get_default_card_software() a bit more standalone by making it a const method that does not mutate the state of the device_image_interface. This is done by passing in a small structure that encapsulates the minimum of information that get_default_card_software() needs.
This also eliminates the need for device_image_interface::open_image_file()
I agree with Sarayan that get_default_card_software() is terrible and needs to ultimately go away. This is a small step in that direction.
Lastly, I don't care for the name of get_default_card_software_hook (or get_default_card_software() for that matter). If anybody has better ideas, let me know.
Diffstat (limited to 'src/emu/dislot.cpp')
-rw-r--r-- | src/emu/dislot.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/emu/dislot.cpp b/src/emu/dislot.cpp index 9546884eccc..7eeeb9a5bf6 100644 --- a/src/emu/dislot.cpp +++ b/src/emu/dislot.cpp @@ -8,6 +8,8 @@ #include "emu.h" #include "emuopts.h" +#include "zippath.h" + // ------------------------------------------------- // ctor @@ -132,3 +134,29 @@ device_slot_card_interface::device_slot_card_interface(const machine_config &mco device_slot_card_interface::~device_slot_card_interface() { } + +get_default_card_software_hook::get_default_card_software_hook(const std::string &path, std::function<bool(util::core_file &, std::string&)> &&get_hashfile_extrainfo) + : m_get_hashfile_extrainfo(std::move(get_hashfile_extrainfo)) + , m_called_get_hashfile_extrainfo(false) + , m_has_hash_extrainfo(false) +{ + if (!path.empty()) + { + std::string revised_path; + util::zippath_fopen(path, OPEN_FLAG_READ, m_image_file, revised_path); + if (m_image_file) + m_file_type = core_filename_extract_extension(revised_path, true); + } +} + +bool get_default_card_software_hook::hashfile_extrainfo(std::string &extrainfo) +{ + if (!m_called_get_hashfile_extrainfo) + { + if (m_get_hashfile_extrainfo) + m_has_hash_extrainfo = m_get_hashfile_extrainfo(*image_file(), m_hash_extrainfo); + m_called_get_hashfile_extrainfo = true; + } + extrainfo = m_hash_extrainfo; + return m_has_hash_extrainfo; +}
\ No newline at end of file |