Fix creation of paths on POSIX

This commit is contained in:
Vas Crabb 2016-03-19 20:06:27 +11:00
parent c30f7e5852
commit 855136bfc3
2 changed files with 57 additions and 57 deletions

View File

@ -822,15 +822,10 @@ void running_machine::call_notifiers(machine_notification which)
void running_machine::handle_saveload()
{
UINT32 openflags = (m_saveload_schedule == SLS_LOAD) ? OPEN_FLAG_READ : (OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
const char *opnamed = (m_saveload_schedule == SLS_LOAD) ? "loaded" : "saved";
const char *opname = (m_saveload_schedule == SLS_LOAD) ? "load" : "save";
osd_file::error filerr = osd_file::error::NONE;
// if no name, bail
emu_file file(m_saveload_searchpath, openflags);
if (m_saveload_pending_file.empty())
goto cancel;
if (!m_saveload_pending_file.empty())
{
const char *const opname = (m_saveload_schedule == SLS_LOAD) ? "load" : "save";
// if there are anonymous timers, we can't save just yet, and we can't load yet either
// because the timers might overwrite data we have loaded
@ -838,17 +833,21 @@ void running_machine::handle_saveload()
{
// if more than a second has passed, we're probably screwed
if ((this->time() - m_saveload_schedule_time) > attotime::from_seconds(1))
{
popmessage("Unable to %s due to pending anonymous timers. See error.log for details.", opname);
goto cancel;
}
return;
else
return; // return without cancelling the operation
}
else
{
UINT32 const openflags = (m_saveload_schedule == SLS_LOAD) ? OPEN_FLAG_READ : (OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
// open the file
filerr = file.open(m_saveload_pending_file.c_str());
emu_file file(m_saveload_searchpath, openflags);
auto const filerr = file.open(m_saveload_pending_file.c_str());
if (filerr == osd_file::error::NONE)
{
const char *const opnamed = (m_saveload_schedule == SLS_LOAD) ? "loaded" : "saved";
// read/write the save state
save_error saverr = (m_saveload_schedule == SLS_LOAD) ? m_save.read_file(file) : m_save.write_file(file);
@ -889,9 +888,10 @@ void running_machine::handle_saveload()
}
else
popmessage("Error: Failed to open file for %s operation.", opname);
}
}
// unschedule the operation
cancel:
m_saveload_pending_file.clear();
m_saveload_searchpath = nullptr;
m_saveload_schedule = SLS_NONE;

View File

@ -247,7 +247,7 @@ osd_file::error osd_file::open(std::string const &path, std::uint32_t openflags,
// create the path if necessary
if ((openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS))
{
auto const pathsep = dst.rfind(dst, PATHSEPCH);
auto const pathsep = dst.rfind(PATHSEPCH);
if (pathsep != std::string::npos)
{
// create the path up to the file