本文整理汇总了C++中chd_file::open方法的典型用法代码示例。如果您正苦于以下问题:C++ chd_file::open方法的具体用法?C++ chd_file::open怎么用?C++ chd_file::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chd_file
的用法示例。
在下文中一共展示了chd_file::open方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: open_chd
static chd_error open_chd(chd_file &file, const char *filename, movie_info &info)
{
// open the file
chd_error chderr = file.open(filename);
if (chderr != CHDERR_NONE)
{
fprintf(stderr, "Error opening CHD file: %s\n", chd_file::error_string(chderr));
return chderr;
}
// get the metadata
astring metadata;
chderr = file.read_metadata(AV_METADATA_TAG, 0, metadata);
if (chderr != CHDERR_NONE)
{
fprintf(stderr, "Error getting A/V metadata: %s\n", chd_file::error_string(chderr));
return chderr;
}
// extract the info
int fps, fpsfrac, width, height, interlaced, channels, rate;
if (sscanf(metadata.c_str(), AV_METADATA_FORMAT, &fps, &fpsfrac, &width, &height, &interlaced, &channels, &rate) != 7)
{
fprintf(stderr, "Improperly formatted metadata\n");
return CHDERR_INVALID_DATA;
}
// extract movie info
info.iframerate = fps * 1000000 + fpsfrac;
info.framerate = info.iframerate / 1000000.0;
info.numfields = file.hunk_count();
info.width = width;
info.height = height;
info.interlaced = interlaced;
info.samplerate = rate;
info.channels = channels;
// allocate buffers
info.bitmap.resize(info.width, info.height);
info.lsound.resize(info.samplerate);
info.rsound.resize(info.samplerate);
return CHDERR_NONE;
}
示例2: open_disk_diff
static chd_error open_disk_diff(emu_options &options, const char *name, chd_file &source, chd_file &diff_chd)
{
std::string fname = std::string(name).append(".dif");
/* try to open the diff */
//printf("Opening differencing image file: %s\n", fname.c_str());
emu_file diff_file(options.diff_directory(), OPEN_FLAG_READ | OPEN_FLAG_WRITE);
osd_file::error filerr = diff_file.open(fname.c_str());
if (filerr == osd_file::error::NONE)
{
std::string fullpath(diff_file.fullpath());
diff_file.close();
//printf("Opening differencing image file: %s\n", fullpath.c_str());
return diff_chd.open(fullpath.c_str(), true, &source);
}
/* didn't work; try creating it instead */
//printf("Creating differencing image: %s\n", fname.c_str());
diff_file.set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
filerr = diff_file.open(fname.c_str());
if (filerr == osd_file::error::NONE)
{
std::string fullpath(diff_file.fullpath());
diff_file.close();
/* create the CHD */
//printf("Creating differencing image file: %s\n", fupointllpath.c_str());
chd_codec_type compression[4] = { CHD_CODEC_NONE };
chd_error err = diff_chd.create(fullpath.c_str(), source.logical_bytes(), source.hunk_bytes(), compression, source);
if (err != CHDERR_NONE)
return err;
return diff_chd.clone_all_metadata(source);
}
return CHDERR_FILE_NOT_FOUND;
}
示例3: open_disk_diff
static chd_error open_disk_diff(emu_options &options, const rom_entry *romp, chd_file &source, chd_file &diff_chd)
{
astring fname(ROM_GETNAME(romp), ".dif");
/* try to open the diff */
LOG(("Opening differencing image file: %s\n", fname.cstr()));
emu_file diff_file(options.diff_directory(), OPEN_FLAG_READ | OPEN_FLAG_WRITE);
file_error filerr = diff_file.open(fname);
if (filerr == FILERR_NONE)
{
astring fullpath(diff_file.fullpath());
diff_file.close();
LOG(("Opening differencing image file: %s\n", fullpath.cstr()));
return diff_chd.open(fullpath, true, &source);
}
/* didn't work; try creating it instead */
LOG(("Creating differencing image: %s\n", fname.cstr()));
diff_file.set_openflags(OPEN_FLAG_READ | OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
filerr = diff_file.open(fname);
if (filerr == FILERR_NONE)
{
astring fullpath(diff_file.fullpath());
diff_file.close();
/* create the CHD */
LOG(("Creating differencing image file: %s\n", fullpath.cstr()));
chd_codec_type compression[4] = { CHD_CODEC_NONE };
chd_error err = diff_chd.create(fullpath, source.logical_bytes(), source.hunk_bytes(), compression, source);
if (err != CHDERR_NONE)
return err;
return diff_chd.clone_all_metadata(source);
}
return CHDERR_FILE_NOT_FOUND;
}
示例4: open_disk_image
int open_disk_image(emu_options &options, const game_driver *gamedrv, const rom_entry *romp, chd_file &image_chd, const char *locationtag)
{
emu_file image_file(options.media_path(), OPEN_FLAG_READ);
const rom_entry *region, *rom;
file_error filerr;
chd_error err;
/* attempt to open the properly named file, scanning up through parent directories */
filerr = FILERR_NOT_FOUND;
for (int searchdrv = driver_list::find(*gamedrv); searchdrv != -1 && filerr != FILERR_NONE; searchdrv = driver_list::clone(searchdrv))
filerr = common_process_file(options, driver_list::driver(searchdrv).name, ".chd", romp, image_file);
if (filerr != FILERR_NONE)
filerr = common_process_file(options, NULL, ".chd", romp, image_file);
/* look for the disk in the locationtag too */
if (filerr != FILERR_NONE && locationtag != NULL)
{
// check if we are dealing with softwarelists. if so, locationtag
// is actually a concatenation of: listname + setname + parentname
// separated by '%' (parentname being present only for clones)
astring tag1(locationtag), tag2, tag3, tag4, tag5;
bool is_list = FALSE;
bool has_parent = FALSE;
int separator1 = tag1.chr(0, '%');
if (separator1 != -1)
{
is_list = TRUE;
// we are loading through softlists, split the listname from the regiontag
tag4.cpysubstr(tag1, separator1 + 1, tag1.len() - separator1 + 1);
tag1.del(separator1, tag1.len() - separator1);
tag1.cat(PATH_SEPARATOR);
// check if we are loading a clone (if this is the case also tag1 have a separator '%')
int separator2 = tag4.chr(0, '%');
if (separator2 != -1)
{
has_parent = TRUE;
// we are loading a clone through softlists, split the setname from the parentname
tag5.cpysubstr(tag4, separator2 + 1, tag4.len() - separator2 + 1);
tag4.del(separator2, tag4.len() - separator2);
}
// prepare locations where we have to load from: list/parentname (if any) & list/clonename
astring swlist(tag1.cstr());
tag2.cpy(swlist.cat(tag4));
if (has_parent)
{
swlist.cpy(tag1);
tag3.cpy(swlist.cat(tag5));
}
}
if (tag5.chr(0, '%') != -1)
fatalerror("We do not support clones of clones!\n");
// try to load from the available location(s):
// - if we are not using lists, we have locationtag only;
// - if we are using lists, we have: list/clonename, list/parentname, clonename, parentname
if (!is_list)
filerr = common_process_file(options, locationtag, ".chd", romp, image_file);
else
{
// try to load from list/setname
if ((filerr != FILERR_NONE) && (tag2.cstr() != NULL))
filerr = common_process_file(options, tag2.cstr(), ".chd", romp, image_file);
// try to load from list/parentname (if any)
if ((filerr != FILERR_NONE) && has_parent && (tag3.cstr() != NULL))
filerr = common_process_file(options, tag3.cstr(), ".chd", romp, image_file);
// try to load from setname
if ((filerr != FILERR_NONE) && (tag4.cstr() != NULL))
filerr = common_process_file(options, tag4.cstr(), ".chd", romp, image_file);
// try to load from parentname (if any)
if ((filerr != FILERR_NONE) && has_parent && (tag5.cstr() != NULL))
filerr = common_process_file(options, tag5.cstr(), ".chd", romp, image_file);
// only for CHD we also try to load from list/
if ((filerr != FILERR_NONE) && (tag1.cstr() != NULL))
{
tag1.del(tag1.len() - 1, 1); // remove the PATH_SEPARATOR
filerr = common_process_file(options, tag1.cstr(), ".chd", romp, image_file);
}
}
}
/* did the file open succeed? */
if (filerr == FILERR_NONE)
{
astring fullpath(image_file.fullpath());
image_file.close();
/* try to open the CHD */
err = image_chd.open(fullpath);
if (err == CHDERR_NONE)
return err;
}
else
err = CHDERR_FILE_NOT_FOUND;
//.........这里部分代码省略.........