当前位置: 首页>>代码示例>>C++>>正文


C++ EMUFILE_FILE::fprintf方法代码示例

本文整理汇总了C++中EMUFILE_FILE::fprintf方法的典型用法代码示例。如果您正苦于以下问题:C++ EMUFILE_FILE::fprintf方法的具体用法?C++ EMUFILE_FILE::fprintf怎么用?C++ EMUFILE_FILE::fprintf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EMUFILE_FILE的用法示例。


在下文中一共展示了EMUFILE_FILE::fprintf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ensure

void BackupDevice::ensure(u32 addr, u8 val, EMUFILE_FILE *fpOut)
{
	if (!fpOut && (addr < fsize)) return;

	EMUFILE_FILE *fp = fpOut?fpOut:fpMC;

#ifndef _DONT_SAVE_BACKUP
	fp->fseek(fsize, SEEK_SET);
#endif
	
	u32 padSize = pad_up_size(addr);
	u32 size = padSize - fsize;
	info.padSize = info.size = fsize = padSize;
	int type = searchFileSaveType(fsize);
	if (type != 0xFF) info.type = (type + 1);

#ifndef _DONT_SAVE_BACKUP
	if (size > 0)
	{
		u8 *tmp = new u8[size];
		memset(tmp, val, size);
		fwrite(tmp, 1, size, fp->get_fp());
		delete [] tmp;
	}

	//this is just for humans to read
	fp->fprintf(DESMUME_BACKUP_FOOTER_TXT);

	//and now the actual footer
	fp->write32le(addr);			//the size of data that has actually been written
	fp->write32le(padSize);			//the size we padded it to
	fp->write32le(info.type);		//save memory type
	fp->write32le(addr_size);
	fp->write32le(info.size);		//save memory size
	fp->write32le((u32)0);		//version number
	fp->fprintf("%s", kDesmumeSaveCookie); //this is what we'll use to recognize the desmume format save

	fp->fflush();

	//this is a HORRIBLE IDEA.
	//leave the FP positioned to write the final byte
	//this is a HACK to make the basic read/write byte operation work when it calls ensure().
	//IDEALLY, no assumptions about the file pointer can be made.
	//but someone (actually, not really) so very carefully profiled the save IO code and discovered that not fseeking for every byte read/write was a great optimization.
	//so, now all this code is depending/assuming on the FP being kept in a precise position, and I dont think its smart to change the main user of this assumption to paper over this bug by making it fseek before read/write, while leaving other unknown assuming clients intact
	fpMC->fseek(addr-1, SEEK_SET);
#endif
}
开发者ID:krysanto,项目名称:desmume,代码行数:48,代码来源:mc.cpp

示例2: ensure

void BackupDevice::ensure(u32 addr, u8 val, EMUFILE_FILE *fpOut)
{
	if (!fpOut && (addr < fsize)) return;

	EMUFILE_FILE *fp = fpOut?fpOut:fpMC;

#ifndef _DONT_SAVE_BACKUP
	fp->fseek(fsize, SEEK_SET);
#endif
	
	u32 padSize = pad_up_size(addr);
	u32 size = padSize - fsize;
	info.padSize = info.size = fsize = padSize;
	int type = searchFileSaveType(fsize);
	if (type != 0xFF) info.type = (type + 1);

#ifndef _DONT_SAVE_BACKUP
	if (size > 0)
	{
		u8 *tmp = new u8[size];
		memset(tmp, val, size);
		fwrite(tmp, 1, size, fp->get_fp());
		delete [] tmp;
	}

	//this is just for humans to read
	fp->fprintf(DESMUME_BACKUP_FOOTER_TXT);

	//and now the actual footer
	fp->write32le(addr);			//the size of data that has actually been written
	fp->write32le(padSize);			//the size we padded it to
	fp->write32le(info.type);		//save memory type
	fp->write32le(addr_size);
	fp->write32le(info.size);		//save memory size
	fp->write32le((u32)0);		//version number
	fp->fprintf("%s", kDesmumeSaveCookie); //this is what we'll use to recognize the desmume format save

	fp->fflush();

	fp->fseek(addr, SEEK_SET);
#endif
}
开发者ID:Annovae,项目名称:desmume,代码行数:42,代码来源:mc.cpp


注:本文中的EMUFILE_FILE::fprintf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。