Merge pull request #1273 from npwoods/more_tafoid_bugs

fix more softlist regressions
This commit is contained in:
Vas Crabb 2016-08-19 23:40:47 +10:00 committed by GitHub
commit a5b10493f6
3 changed files with 15 additions and 16 deletions

View File

@ -740,20 +740,21 @@ int device_image_interface::reopen_for_write(const std::string &path)
// flags to use, and in what order // flags to use, and in what order
//------------------------------------------------- //-------------------------------------------------
void device_image_interface::determine_open_plan(int is_create, UINT32 *open_plan) std::vector<UINT32> device_image_interface::determine_open_plan(bool is_create)
{ {
int i = 0; std::vector<UINT32> open_plan;
// emit flags // emit flags into a vector
if (!is_create && is_readable() && is_writeable()) 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()) 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()) if (!is_create && is_readable())
open_plan[i++] = OPEN_FLAG_READ; open_plan.push_back(OPEN_FLAG_READ);
if (is_writeable() && is_creatable()) if (is_create && is_writeable() && is_creatable())
open_plan[i++] = OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE; open_plan.push_back(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE);
open_plan[i] = 0;
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) 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 // first unload the image
unload(); unload();
@ -940,13 +938,13 @@ image_init_result device_image_interface::load_internal(const std::string &path,
if (core_opens_image_file()) if (core_opens_image_file())
{ {
// determine open plan // determine open plan
determine_open_plan(is_create, open_plan); std::vector<UINT32> open_plan = determine_open_plan(is_create);
// attempt to open the file in various ways // 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 // 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)) if (m_err && (m_err != IMAGE_ERROR_FILENOTFOUND))
goto done; goto done;
} }

View File

@ -252,7 +252,6 @@ protected:
virtual const software_list_loader &get_software_list_loader() const; 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); 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); image_error_t load_image_by_path(UINT32 open_flags, const std::string &path);
void clear(); void clear();
bool is_loaded(); bool is_loaded();
@ -304,6 +303,7 @@ protected:
private: private:
static image_error_t image_error_from_file_error(osd_file::error filerr); static image_error_t image_error_from_file_error(osd_file::error filerr);
bool schedule_postload_hard_reset_if_needed(); bool schedule_postload_hard_reset_if_needed();
std::vector<UINT32> determine_open_plan(bool is_create);
// creation info // creation info
formatlist_type m_formatlist; formatlist_type m_formatlist;

View File

@ -485,6 +485,7 @@ osd_file::error win_error_to_file_error(DWORD error)
case ERROR_FILE_NOT_FOUND: case ERROR_FILE_NOT_FOUND:
case ERROR_FILENAME_EXCED_RANGE: case ERROR_FILENAME_EXCED_RANGE:
case ERROR_PATH_NOT_FOUND: case ERROR_PATH_NOT_FOUND:
case ERROR_INVALID_NAME:
filerr = osd_file::error::NOT_FOUND; filerr = osd_file::error::NOT_FOUND;
break; break;