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,76 +822,76 @@ 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 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
if (!m_scheduler.can_save())
if (!m_saveload_pending_file.empty())
{
// if more than a second has passed, we're probably screwed
if ((this->time() - m_saveload_schedule_time) > attotime::from_seconds(1))
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
if (!m_scheduler.can_save())
{
popmessage("Unable to %s due to pending anonymous timers. See error.log for details.", opname);
goto cancel;
// 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);
else
return; // return without cancelling the operation
}
return;
}
// open the file
filerr = file.open(m_saveload_pending_file.c_str());
if (filerr == osd_file::error::NONE)
{
// read/write the save state
save_error saverr = (m_saveload_schedule == SLS_LOAD) ? m_save.read_file(file) : m_save.write_file(file);
// handle the result
switch (saverr)
else
{
case STATERR_ILLEGAL_REGISTRATIONS:
popmessage("Error: Unable to %s state due to illegal registrations. See error.log for details.", opname);
break;
UINT32 const openflags = (m_saveload_schedule == SLS_LOAD) ? OPEN_FLAG_READ : (OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
case STATERR_INVALID_HEADER:
popmessage("Error: Unable to %s state due to an invalid header. Make sure the save state is correct for this game.", opname);
break;
// open the file
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";
case STATERR_READ_ERROR:
popmessage("Error: Unable to %s state due to a read error (file is likely corrupt).", opname);
break;
// read/write the save state
save_error saverr = (m_saveload_schedule == SLS_LOAD) ? m_save.read_file(file) : m_save.write_file(file);
case STATERR_WRITE_ERROR:
popmessage("Error: Unable to %s state due to a write error. Verify there is enough disk space.", opname);
break;
// handle the result
switch (saverr)
{
case STATERR_ILLEGAL_REGISTRATIONS:
popmessage("Error: Unable to %s state due to illegal registrations. See error.log for details.", opname);
break;
case STATERR_NONE:
if (!(m_system.flags & MACHINE_SUPPORTS_SAVE))
popmessage("State successfully %s.\nWarning: Save states are not officially supported for this game.", opnamed);
else
popmessage("State successfully %s.", opnamed);
break;
case STATERR_INVALID_HEADER:
popmessage("Error: Unable to %s state due to an invalid header. Make sure the save state is correct for this game.", opname);
break;
default:
popmessage("Error: Unknown error during state %s.", opnamed);
break;
case STATERR_READ_ERROR:
popmessage("Error: Unable to %s state due to a read error (file is likely corrupt).", opname);
break;
case STATERR_WRITE_ERROR:
popmessage("Error: Unable to %s state due to a write error. Verify there is enough disk space.", opname);
break;
case STATERR_NONE:
if (!(m_system.flags & MACHINE_SUPPORTS_SAVE))
popmessage("State successfully %s.\nWarning: Save states are not officially supported for this game.", opnamed);
else
popmessage("State successfully %s.", opnamed);
break;
default:
popmessage("Error: Unknown error during state %s.", opnamed);
break;
}
// close and perhaps delete the file
if (saverr != STATERR_NONE && m_saveload_schedule == SLS_SAVE)
file.remove_on_close();
}
else
popmessage("Error: Failed to open file for %s operation.", opname);
}
// close and perhaps delete the file
if (saverr != STATERR_NONE && m_saveload_schedule == SLS_SAVE)
file.remove_on_close();
}
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