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
//-------------------------------------------------
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())
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<UINT32> 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;
}

View File

@ -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<UINT32> determine_open_plan(bool is_create);
// creation info
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_FILENAME_EXCED_RANGE:
case ERROR_PATH_NOT_FOUND:
case ERROR_INVALID_NAME:
filerr = osd_file::error::NOT_FOUND;
break;