本文整理汇总了C++中EMUFILE_FILE::fread方法的典型用法代码示例。如果您正苦于以下问题:C++ EMUFILE_FILE::fread方法的具体用法?C++ EMUFILE_FILE::fread怎么用?C++ EMUFILE_FILE::fread使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EMUFILE_FILE
的用法示例。
在下文中一共展示了EMUFILE_FILE::fread方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadfile
void BackupDevice::loadfile()
{
//never use save files if we are in movie mode
if(isMovieMode) return;
if(filename.length() ==0) return; //No sense crashing if no filename supplied
EMUFILE_FILE* inf = new EMUFILE_FILE(filename.c_str(),"rb");
if(inf->fail())
{
delete inf;
//no dsv found; we need to try auto-importing a file with .sav extension
printf("DeSmuME .dsv save file not found. Trying to load an old raw .sav file.\n");
//change extension to sav
char tmp[MAX_PATH];
strcpy(tmp,filename.c_str());
tmp[strlen(tmp)-3] = 0;
strcat(tmp,"sav");
inf = new EMUFILE_FILE(tmp,"rb");
if(inf->fail())
{
delete inf;
printf("Missing save file %s\n",filename.c_str());
return;
}
delete inf;
if (!load_no_gba(tmp))
load_raw(tmp);
}
else
{
//scan for desmume save footer
const s32 cookieLen = (s32)strlen(kDesmumeSaveCookie);
char *sigbuf = new char[cookieLen];
inf->fseek(-cookieLen, SEEK_END);
inf->fread(sigbuf,cookieLen);
int cmp = memcmp(sigbuf,kDesmumeSaveCookie,cookieLen);
delete[] sigbuf;
if(cmp)
{
//maybe it is a misnamed raw save file. try loading it that way
printf("Not a DeSmuME .dsv save file. Trying to load as raw.\n");
delete inf;
if (!load_no_gba(filename.c_str()))
load_raw(filename.c_str());
return;
}
//desmume format
inf->fseek(-cookieLen, SEEK_END);
inf->fseek(-4, SEEK_CUR);
u32 version = 0xFFFFFFFF;
read32le(&version,inf);
if(version!=0) {
printf("Unknown save file format\n");
return;
}
inf->fseek(-24, SEEK_CUR);
read32le(&info.size,inf);
read32le(&info.padSize,inf);
read32le(&info.type,inf);
read32le(&info.addr_size,inf);
read32le(&info.mem_size,inf);
u32 left = 0;
if (CommonSettings.autodetectBackupMethod == 1)
{
if (advsc.isLoaded())
{
info.type = advsc.getSaveType();
if (info.type != 0xFF || info.type != 0xFE)
{
u32 adv_size = save_types[info.type+1][1];
if (info.size > adv_size)
info.size = adv_size;
else
if (info.size < adv_size)
{
left = adv_size - info.size;
info.size = adv_size;
}
}
}
}
//establish the save data
resize(info.size);
inf->fseek(0, SEEK_SET);
if(info.size>0)
inf->fread(&data[0],info.size - left); //read all the raw data we have
state = RUNNING;
addr_size = info.addr_size;
//none of the other fields are used right now
if (CommonSettings.autodetectBackupMethod != 1 && info.type == 0)
{
info.type = searchFileSaveType(info.size);
if (info.type == 0xFF) info.type = 0;
}
//.........这里部分代码省略.........