mirror of
https://github.com/holub/mame
synced 2025-10-08 17:37:56 +03:00
Fix creation of paths on POSIX
This commit is contained in:
parent
c30f7e5852
commit
855136bfc3
@ -822,76 +822,76 @@ void running_machine::call_notifiers(machine_notification which)
|
|||||||
|
|
||||||
void running_machine::handle_saveload()
|
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
|
// if no name, bail
|
||||||
emu_file file(m_saveload_searchpath, openflags);
|
if (!m_saveload_pending_file.empty())
|
||||||
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 more than a second has passed, we're probably screwed
|
const char *const opname = (m_saveload_schedule == SLS_LOAD) ? "load" : "save";
|
||||||
if ((this->time() - m_saveload_schedule_time) > attotime::from_seconds(1))
|
|
||||||
|
// 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);
|
// if more than a second has passed, we're probably screwed
|
||||||
goto cancel;
|
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;
|
else
|
||||||
}
|
|
||||||
|
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
case STATERR_ILLEGAL_REGISTRATIONS:
|
UINT32 const openflags = (m_saveload_schedule == SLS_LOAD) ? OPEN_FLAG_READ : (OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
|
||||||
popmessage("Error: Unable to %s state due to illegal registrations. See error.log for details.", opname);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case STATERR_INVALID_HEADER:
|
// open the file
|
||||||
popmessage("Error: Unable to %s state due to an invalid header. Make sure the save state is correct for this game.", opname);
|
emu_file file(m_saveload_searchpath, openflags);
|
||||||
break;
|
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:
|
// read/write the save state
|
||||||
popmessage("Error: Unable to %s state due to a read error (file is likely corrupt).", opname);
|
save_error saverr = (m_saveload_schedule == SLS_LOAD) ? m_save.read_file(file) : m_save.write_file(file);
|
||||||
break;
|
|
||||||
|
|
||||||
case STATERR_WRITE_ERROR:
|
// handle the result
|
||||||
popmessage("Error: Unable to %s state due to a write error. Verify there is enough disk space.", opname);
|
switch (saverr)
|
||||||
break;
|
{
|
||||||
|
case STATERR_ILLEGAL_REGISTRATIONS:
|
||||||
|
popmessage("Error: Unable to %s state due to illegal registrations. See error.log for details.", opname);
|
||||||
|
break;
|
||||||
|
|
||||||
case STATERR_NONE:
|
case STATERR_INVALID_HEADER:
|
||||||
if (!(m_system.flags & MACHINE_SUPPORTS_SAVE))
|
popmessage("Error: Unable to %s state due to an invalid header. Make sure the save state is correct for this game.", opname);
|
||||||
popmessage("State successfully %s.\nWarning: Save states are not officially supported for this game.", opnamed);
|
break;
|
||||||
else
|
|
||||||
popmessage("State successfully %s.", opnamed);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
case STATERR_READ_ERROR:
|
||||||
popmessage("Error: Unknown error during state %s.", opnamed);
|
popmessage("Error: Unable to %s state due to a read error (file is likely corrupt).", opname);
|
||||||
break;
|
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
|
// unschedule the operation
|
||||||
cancel:
|
|
||||||
m_saveload_pending_file.clear();
|
m_saveload_pending_file.clear();
|
||||||
m_saveload_searchpath = nullptr;
|
m_saveload_searchpath = nullptr;
|
||||||
m_saveload_schedule = SLS_NONE;
|
m_saveload_schedule = SLS_NONE;
|
||||||
|
@ -247,7 +247,7 @@ osd_file::error osd_file::open(std::string const &path, std::uint32_t openflags,
|
|||||||
// create the path if necessary
|
// create the path if necessary
|
||||||
if ((openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS))
|
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)
|
if (pathsep != std::string::npos)
|
||||||
{
|
{
|
||||||
// create the path up to the file
|
// create the path up to the file
|
||||||
|
Loading…
Reference in New Issue
Block a user