From db53f51ffc29d35ccd797ea7356fa9275372466d Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Fri, 19 Aug 2016 08:23:56 -0400 Subject: [PATCH 1/2] Now reporting Windows ERROR_INVALID_NAME as osd_file::error::NOT_FOUND --- src/osd/modules/file/winfile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp index 62f5681e697..f275f605b79 100644 --- a/src/osd/modules/file/winfile.cpp +++ b/src/osd/modules/file/winfile.cpp @@ -485,6 +485,7 @@ osd_file::error win_error_to_file_error(DWORD error) case ERROR_FILE_NOT_FOUND: case ERROR_FILENAME_EXCED_RANGE: case ERROR_PATH_NOT_FOUND: + case ERROR_INVALID_NAME: filerr = osd_file::error::NOT_FOUND; break; From a4f59b324284bf7a8c477f2d746e72d4b41b8c3d Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Fri, 19 Aug 2016 08:24:23 -0400 Subject: [PATCH 2/2] Changing device_image_interface::determine_open_plan() to not support creating an image unless device_image_interface::create() is used I'm somewhat surprised that this has not bit us until now. The implication of how it used to work is that device_image_interface::load() could actually create images; it is hard to eliminate the possibility that something might be incorrectly relying on this behavior. I've determined that this isn't the case for imgcntrl.cpp and floppycntrl.cpp --- src/emu/diimage.cpp | 28 +++++++++++++--------------- src/emu/diimage.h | 2 +- 2 files changed, 14 insertions(+), 16 deletions(-) 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;