本文整理汇总了C++中EMUFILE::fail方法的典型用法代码示例。如果您正苦于以下问题:C++ EMUFILE::fail方法的具体用法?C++ EMUFILE::fail怎么用?C++ EMUFILE::fail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EMUFILE
的用法示例。
在下文中一共展示了EMUFILE::fail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: flush
void BackupDevice::flush()
{
//never use save files if we are in movie mode
if(isMovieMode) return;
if (filename.length() == 0) return;
EMUFILE* outf = new EMUFILE_FILE(filename.c_str(),"wb");
if(!outf->fail())
{
if(data.size()>0)
outf->fwrite(&data[0],data.size());
//write the footer. we use a footer so that we can maximize the chance of the
//save file being recognized as a raw save file by other emulators etc.
//first, pad up to the next largest known save size.
u32 size = data.size();
u32 padSize = pad_up_size(size);
for(u32 i=size;i<padSize;i++)
outf->fputc(kUninitializedSaveDataValue);
//this is just for humans to read
outf->fprintf("|<--Snip above here to create a raw sav by excluding this DeSmuME savedata footer:");
//and now the actual footer
write32le(size,outf); //the size of data that has actually been written
write32le(padSize,outf); //the size we padded it to
write32le(info.type,outf); //save memory type
write32le(addr_size,outf);
write32le(info.size,outf); //save memory size
write32le(0,outf); //version number
outf->fprintf("%s", kDesmumeSaveCookie); //this is what we'll use to recognize the desmume format save
delete outf;
}
else
{
delete outf;
printf("Unable to open savefile %s\n", filename.c_str());
}
}
示例2: connect
virtual void connect()
{
Close();
romSize = 0;
sramSize = 0;
if (gameInfo.romsize == 0)
{
return;
}
if (GBACartridge_RomPath.empty())
{
return;
}
if (!strcasecmp(GBACartridge_RomPath.c_str(), "self"))
{
GBACartridge_RomPath = path.path;
GBACartridge_SRAMPath = Path::GetFileNameWithoutExt(GBACartridge_RomPath) + "." + GBA_SRAM_FILE_EXT;
}
printf("GBASlot opening ROM: %s\n", GBACartridge_RomPath.c_str());
EMUFILE_FILE *inf = new EMUFILE_FILE(GBACartridge_RomPath, "rb");
inf->EnablePositionCache();
fROM = inf;
if (fROM->fail())
{
printf(" - Failed\n");
Close();
return;
}
romSize = fROM->size();
printf(" - Success (%u bytes)\n", romSize);
// Load the GBA cartridge SRAM.
inf = new EMUFILE_FILE(GBACartridge_SRAMPath, "rb+");
fSRAM = inf;
if(fSRAM->fail())
{
delete fSRAM;
fSRAM = NULL;
printf("GBASlot did not load associated SRAM.\n");
}
else
{
inf->EnablePositionCache();
sramSize = fSRAM->size();
printf("Scanning GBA rom to ID save type\n");
saveType = scanSaveTypeGBA();
printf("\nGBASlot found SRAM (%s - %u bytes) at:\n%s\n", (saveType == 0xFF)?"Unknown":saveTypes[saveType], sramSize, GBACartridge_SRAMPath.c_str());
gbaFlash.size = sramSize;
if (gbaFlash.size <= (64 * 1024))
{
gbaFlash.idDevice = 0x1B;
gbaFlash.idManufacturer = 0x32;
}
else
{
gbaFlash.idDevice = 0x09;
gbaFlash.idManufacturer = 0xC2;
}
gbaFlash.state = 0;
}
}