diff options
author | 2022-09-19 02:33:50 -0400 | |
---|---|---|
committer | 2022-09-19 08:33:50 +0200 | |
commit | 5499683a239d9328a7c54b08135f31e7903ec772 (patch) | |
tree | e439ca5174cec47008c571f9c2636a5d4da68d81 /src/tools/image_handler.cpp | |
parent | e1e30896f5cc3fd736564a9dea25d255241f6777 (diff) |
Changed fs::manager_t::enumerate_f() to simplify logic within file system drivers (#10106)
* Changed fs::manager_t::enumerate_f() to simplify logic within file system drivers
enumerate_f() used to contain quite a bit of boilerplate logic to determine whether a particular floppy type should be added. This change attempts to move this logic outside the file system drivers to simplify the drivers.
The riskiest part of this change is unformatted_image::enumerate_f(). I attempted to replicate the logic that was previously determining with unformatted image types to use, but the logic is tricky and it isn't clear to me that replicating the logic is the correct action - I may be cargo culting.
* Fix to floppy_image_device::fs_enum::add_raw()
* Updating FS_FAT to reflect this PR
* On the advise of Sarayan, I moved the filtering to the fs::manager_t::fs_enum base class. This is actually a less intrusive change than what I originally had because it keeps the unformatted raw image handling closer to what we had previously.
Some misgivings about these changes:
1. We now have fs::manager_t::fs_enum::add() being a thin call that invokes a protected method called fs::manager_t::fs_enum::add_format(). Better ideas for names are welcome.
2. It feels odd that we've removed the need to do filtering from the various FS modules, but the unformatted module has to ask the fs_enum() for its internal variables for filtering to perform the same logic. This seems to be the least worst option
Feedback is welcome
Diffstat (limited to 'src/tools/image_handler.cpp')
-rw-r--r-- | src/tools/image_handler.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/tools/image_handler.cpp b/src/tools/image_handler.cpp index 02328059490..44d7fce7df3 100644 --- a/src/tools/image_handler.cpp +++ b/src/tools/image_handler.cpp @@ -42,10 +42,9 @@ namespace { struct fs_enum : public fs::manager_t::floppy_enumerator { filesystem_format *m_format; + fs_enum(filesystem_format *format, const std::vector<u32> &variants) : fs::manager_t::floppy_enumerator(floppy_image::FF_UNKNOWN, variants), m_format(format) {} - fs_enum(filesystem_format *format) : m_format(format) {} - - virtual void add(const floppy_image_format_t &type, u32 image_size, const char *name, const char *description) override { + virtual void add_format(const floppy_image_format_t &type, u32 image_size, const char *name, const char *description) override { m_format->m_floppy = true; m_format->m_floppy_create.emplace_back(std::make_unique<floppy_create_info>(m_format->m_manager, &type, image_size, name, description)); } @@ -65,8 +64,8 @@ void formats_table::init() mame_formats_full_list(en); for(auto &f : filesystem_formats) { - fs_enum fen(f.get()); - f->m_manager->enumerate_f(fen, floppy_image::FF_UNKNOWN, variants); + fs_enum fen(f.get(), variants); + f->m_manager->enumerate_f(fen); } for(auto &f : floppy_format_infos) { |