mirror of
https://github.com/holub/mame
synced 2025-10-09 17:53:01 +03:00
Fix creation of paths on POSIX
This commit is contained in:
parent
c30f7e5852
commit
855136bfc3
@ -822,15 +822,10 @@ 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;
|
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
|
// 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
|
// 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 more than a second has passed, we're probably screwed
|
||||||
if ((this->time() - m_saveload_schedule_time) > attotime::from_seconds(1))
|
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);
|
popmessage("Unable to %s due to pending anonymous timers. See error.log for details.", opname);
|
||||||
goto cancel;
|
else
|
||||||
}
|
return; // return without cancelling the operation
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
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
|
// 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)
|
if (filerr == osd_file::error::NONE)
|
||||||
{
|
{
|
||||||
|
const char *const opnamed = (m_saveload_schedule == SLS_LOAD) ? "loaded" : "saved";
|
||||||
|
|
||||||
// read/write the save state
|
// read/write the save state
|
||||||
save_error saverr = (m_saveload_schedule == SLS_LOAD) ? m_save.read_file(file) : m_save.write_file(file);
|
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
|
else
|
||||||
popmessage("Error: Failed to open file for %s operation.", opname);
|
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