mirror of
https://github.com/holub/mame
synced 2025-10-06 17:08:28 +03:00
Introduced running_machine::compose_saveload_filename() function to convert a filename (for state save/load) to a fully qualified path
This commit is contained in:
parent
1d1bef77f6
commit
4c25315d59
@ -549,6 +549,39 @@ std::string running_machine::get_statename(const char *option) const
|
|||||||
return statename_str;
|
return statename_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// compose_saveload_filename - composes a filename
|
||||||
|
// for state loading/saving
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
std::string running_machine::compose_saveload_filename(const char *filename, const char **searchpath)
|
||||||
|
{
|
||||||
|
std::string result;
|
||||||
|
|
||||||
|
// is this an absolute path?
|
||||||
|
if (osd_is_absolute_path(filename))
|
||||||
|
{
|
||||||
|
// if so, this is easy
|
||||||
|
if (searchpath != nullptr)
|
||||||
|
*searchpath = nullptr;
|
||||||
|
result = filename;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// this is a relative path; first specify the search path
|
||||||
|
if (searchpath != nullptr)
|
||||||
|
*searchpath = options().state_directory();
|
||||||
|
|
||||||
|
// take into account the statename option
|
||||||
|
const char *stateopt = options().state_name();
|
||||||
|
std::string statename = get_statename(stateopt);
|
||||||
|
result = string_format("%s%s%s.sta", statename, PATH_SEPARATOR, filename);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------
|
//-------------------------------------------------
|
||||||
// set_saveload_filename - specifies the filename
|
// set_saveload_filename - specifies the filename
|
||||||
// for state loading/saving
|
// for state loading/saving
|
||||||
@ -556,20 +589,8 @@ std::string running_machine::get_statename(const char *option) const
|
|||||||
|
|
||||||
void running_machine::set_saveload_filename(const char *filename)
|
void running_machine::set_saveload_filename(const char *filename)
|
||||||
{
|
{
|
||||||
// free any existing request and allocate a copy of the requested name
|
// compose the save/load filename and persist it
|
||||||
if (osd_is_absolute_path(filename))
|
m_saveload_pending_file = compose_saveload_filename(filename, &m_saveload_searchpath);
|
||||||
{
|
|
||||||
m_saveload_searchpath = nullptr;
|
|
||||||
m_saveload_pending_file.assign(filename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_saveload_searchpath = options().state_directory();
|
|
||||||
// take into account the statename option
|
|
||||||
const char *stateopt = options().state_name();
|
|
||||||
std::string statename = get_statename(stateopt);
|
|
||||||
m_saveload_pending_file = string_format("%s%s%s.sta", statename, PATH_SEPARATOR, filename);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -234,6 +234,7 @@ public:
|
|||||||
void strlog(const char *str) const;
|
void strlog(const char *str) const;
|
||||||
UINT32 rand();
|
UINT32 rand();
|
||||||
const char *describe_context();
|
const char *describe_context();
|
||||||
|
std::string compose_saveload_filename(const char *base_filename, const char **searchpath = nullptr);
|
||||||
|
|
||||||
// CPU information
|
// CPU information
|
||||||
cpu_device * firstcpu; // first CPU
|
cpu_device * firstcpu; // first CPU
|
||||||
|
Loading…
Reference in New Issue
Block a user