本文整理汇总了C++中emu_file::open方法的典型用法代码示例。如果您正苦于以下问题:C++ emu_file::open方法的具体用法?C++ emu_file::open怎么用?C++ emu_file::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类emu_file
的用法示例。
在下文中一共展示了emu_file::open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: common_process_file
file_error common_process_file(emu_options &options, const char *location, const char *ext, const rom_entry *romp, emu_file &image_file)
{
file_error filerr;
if (location != NULL && strcmp(location, "") != 0)
filerr = image_file.open(location, PATH_SEPARATOR, ROM_GETNAME(romp), ext);
else
filerr = image_file.open(ROM_GETNAME(romp), ext);
return filerr;
}
示例2: open_next
osd_file::error video_manager::open_next(emu_file &file, const char *extension)
{
UINT32 origflags = file.openflags();
// handle defaults
const char *snapname = machine().options().snap_name();
if (snapname == nullptr || snapname[0] == 0)
snapname = "%g/%i";
std::string snapstr(snapname);
// strip any extension in the provided name
int index = snapstr.find_last_of('.');
if (index != -1)
snapstr = snapstr.substr(0, index);
// handle %d in the template (for image devices)
std::string snapdev("%d_");
int pos = snapstr.find(snapdev);
if (pos != -1)
{
// if more %d are found, revert to default and ignore them all
if (snapstr.find(snapdev.c_str(), pos + 3) != -1)
snapstr.assign("%g/%i");
// else if there is a single %d, try to create the correct snapname
else
{
int name_found = 0;
// find length of the device name
int end1 = snapstr.find("/", pos + 3);
int end2 = snapstr.find("%", pos + 3);
int end;
if ((end1 != -1) && (end2 != -1))
end = MIN(end1, end2);
else if (end1 != -1)
end = end1;
else if (end2 != -1)
end = end2;
else
end = snapstr.length();
if (end - pos < 3)
fatalerror("Something very wrong is going on!!!\n");
// copy the device name to an std::string
std::string snapdevname;
snapdevname.assign(snapstr.substr(pos + 3, end - pos - 3));
//printf("check template: %s\n", snapdevname.c_str());
// verify that there is such a device for this system
image_interface_iterator iter(machine().root_device());
for (device_image_interface *image = iter.first(); image != nullptr; image = iter.next())
{
// get the device name
std::string tempdevname(image->brief_instance_name());
//printf("check device: %s\n", tempdevname.c_str());
if (snapdevname.compare(tempdevname) == 0)
{
// verify that such a device has an image mounted
if (image->basename() != nullptr)
{
std::string filename(image->basename());
// strip extension
filename = filename.substr(0, filename.find_last_of('.'));
// setup snapname and remove the %d_
strreplace(snapstr, snapdevname.c_str(), filename.c_str());
snapstr.erase(pos, 3);
//printf("check image: %s\n", filename.c_str());
name_found = 1;
}
}
}
// or fallback to default
if (name_found == 0)
snapstr.assign("%g/%i");
}
}
// add our own extension
snapstr.append(".").append(extension);
// substitute path and gamename up front
strreplace(snapstr, "/", PATH_SEPARATOR);
strreplace(snapstr, "%g", machine().basename());
// determine if the template has an index; if not, we always use the same name
std::string fname;
if (snapstr.find("%i") == -1)
fname.assign(snapstr);
// otherwise, we scan for the next available filename
else
//.........这里部分代码省略.........
示例3: open_next
file_error video_manager::open_next(emu_file &file, const char *extension)
{
UINT32 origflags = file.openflags();
// handle defaults
const char *snapname = machine().options().snap_name();
if (snapname == NULL || snapname[0] == 0)
snapname = "%g/%i";
astring snapstr(snapname);
// strip any extension in the provided name
int index = snapstr.rchr(0, '.');
if (index != -1)
snapstr.substr(0, index);
// handle %d in the template (for image devices)
astring snapdev("%d_");
int pos = snapstr.find(0, snapdev);
if (pos != -1)
{
// if more %d are found, revert to default and ignore them all
if (snapstr.find(pos + 3, snapdev) != -1)
snapstr.cpy("%g/%i");
// else if there is a single %d, try to create the correct snapname
else
{
int name_found = 0;
// find length of the device name
int end1 = snapstr.find(pos + 3, "/");
int end2 = snapstr.find(pos + 3, "%");
int end = -1;
if ((end1 != -1) && (end2 != -1))
end = MIN(end1, end2);
else if (end1 != -1)
end = end1;
else if (end2 != -1)
end = end2;
else
end = snapstr.len();
if (end - pos < 3)
fatalerror("Something very wrong is going on!!!");
// copy the device name to an astring
astring snapdevname;
snapdevname.cpysubstr(snapstr, pos + 3, end - pos - 3);
//printf("check template: %s\n", snapdevname.cstr());
// verify that there is such a device for this system
device_image_interface *image = NULL;
for (bool gotone = machine().devicelist().first(image); gotone; gotone = image->next(image))
{
// get the device name
astring tempdevname(image->brief_instance_name());
//printf("check device: %s\n", tempdevname.cstr());
if (snapdevname.cmp(tempdevname) == 0)
{
// verify that such a device has an image mounted
if (image->basename() != NULL)
{
astring filename(image->basename());
// strip extension
filename.substr(0, filename.rchr(0, '.'));
// setup snapname and remove the %d_
snapstr.replace(0, snapdevname, filename);
snapstr.del(pos, 3);
//printf("check image: %s\n", filename.cstr());
name_found = 1;
}
}
}
// or fallback to default
if (name_found == 0)
snapstr.cpy("%g/%i");
}
}
// add our own extension
snapstr.cat(".").cat(extension);
// substitute path and gamename up front
snapstr.replace(0, "/", PATH_SEPARATOR);
snapstr.replace(0, "%g", machine().basename());
// determine if the template has an index; if not, we always use the same name
astring fname;
if (snapstr.find(0, "%i") == -1)
fname.cpy(snapstr);
// otherwise, we scan for the next available filename
else
//.........这里部分代码省略.........