diff --git a/src/emu/diimage.cpp b/src/emu/diimage.cpp index d4d2be3d4b5..1e0705e46e4 100644 --- a/src/emu/diimage.cpp +++ b/src/emu/diimage.cpp @@ -740,20 +740,21 @@ int device_image_interface::reopen_for_write(const std::string &path) // flags to use, and in what order //------------------------------------------------- -void device_image_interface::determine_open_plan(int is_create, UINT32 *open_plan) +std::vector device_image_interface::determine_open_plan(bool is_create) { - int i = 0; + std::vector open_plan; - // emit flags + // emit flags into a vector if (!is_create && is_readable() && is_writeable()) - open_plan[i++] = OPEN_FLAG_READ | OPEN_FLAG_WRITE; + open_plan.push_back(OPEN_FLAG_READ | OPEN_FLAG_WRITE); if (!is_create && !is_readable() && is_writeable()) - open_plan[i++] = OPEN_FLAG_WRITE; + open_plan.push_back(OPEN_FLAG_WRITE); if (!is_create && is_readable()) - open_plan[i++] = OPEN_FLAG_READ; - if (is_writeable() && is_creatable()) - open_plan[i++] = OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE; - open_plan[i] = 0; + open_plan.push_back(OPEN_FLAG_READ); + if (is_create && is_writeable() && is_creatable()) + open_plan.push_back(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE); + + return open_plan; } @@ -922,9 +923,6 @@ bool device_image_interface::load_software(software_list_device &swlist, const c image_init_result device_image_interface::load_internal(const std::string &path, bool is_create, int create_format, util::option_resolution *create_args, bool just_load) { - UINT32 open_plan[4]; - int i; - // first unload the image unload(); @@ -940,13 +938,13 @@ image_init_result device_image_interface::load_internal(const std::string &path, if (core_opens_image_file()) { // determine open plan - determine_open_plan(is_create, open_plan); + std::vector open_plan = determine_open_plan(is_create); // attempt to open the file in various ways - for (i = 0; !m_file && open_plan[i]; i++) + for (auto iter = open_plan.cbegin(); !m_file && iter != open_plan.cend(); iter++) { // open the file - m_err = load_image_by_path(open_plan[i], path); + m_err = load_image_by_path(*iter, path); if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND)) goto done; } diff --git a/src/emu/diimage.h b/src/emu/diimage.h index aac698230b8..2558c40bbcc 100644 --- a/src/emu/diimage.h +++ b/src/emu/diimage.h @@ -252,7 +252,6 @@ protected: virtual const software_list_loader &get_software_list_loader() const; image_init_result load_internal(const std::string &path, bool is_create, int create_format, util::option_resolution *create_args, bool just_load); - void determine_open_plan(int is_create, UINT32 *open_plan); image_error_t load_image_by_path(UINT32 open_flags, const std::string &path); void clear(); bool is_loaded(); @@ -304,6 +303,7 @@ protected: private: static image_error_t image_error_from_file_error(osd_file::error filerr); bool schedule_postload_hard_reset_if_needed(); + std::vector determine_open_plan(bool is_create); // creation info formatlist_type m_formatlist;