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


C++ Compressor::isFileLoaded方法代码示例

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


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

示例1: detectFormat_fopen

/**
 * detectFormat_fopen(): Detect the format of a given ROM file.
 * @param filename Filename of the ROM file.
 * @return ROMType.
 */
ROMType ROM::detectFormat_fopen(const char* filename)
{
	Compressor *cmp;
	list<CompressedFile> *files;
	ROMType rtype;
	
	// Open the ROM file using the compressor functions.
	cmp = new Compressor(filename);
	if (!cmp->isFileLoaded())
	{
		// Cannot load the file.
		delete cmp;
		return (ROMType)0;
	}
	
	// Get the file information.
	files = cmp->getFileInfo();
	
	// Check how many files are available.
	if (!files || files->empty())
	{
		// No files.
		delete files;
		delete cmp;
		return (ROMType)0;
	}
	
	// Get the first file in the archive.
	// TODO: Store the compressed filename in ROM history.
	unsigned char detectBuf[2048];
	cmp->getFile(&(*files->begin()), detectBuf, sizeof(detectBuf));
	rtype = detectFormat(detectBuf);
	
	// Return the ROM type.
	delete files;
	delete cmp;
	return rtype;
}
开发者ID:chipsoftwaretester,项目名称:OpenEmu,代码行数:43,代码来源:rom.cpp

示例2: loadROM

/**
 * loadROM(): Load a ROM file.
 * @param filename Filename of the ROM file.
 * @param interleaved If non-zero, the ROM is interleaved.
 * @return Pointer to Rom struct with the ROM information.
 */
ROMType ROM::loadROM(const char* filename, ROM_t** retROM)
{
	Compressor *cmp;
	list<CompressedFile> *files;
	CompressedFile* selFile;
	ROMType rtype;
	
	// Set up the compressor.
	cmp = new Compressor(filename, true);
	if (!cmp->isFileLoaded())
	{
		// Error loading the file.
		delete cmp;
		Game = NULL;
		*retROM = NULL;
		return (ROMType)0;
	}
	
	// Get the file information.
	files = cmp->getFileInfo();
	
	// Check how many files are available.
	if (!files || files->empty())
	{
		// No files in the archive.
		// TODO: For 7z, suggest setting the 7z binary filename.
		GensUI::msgBox("No files were detected in this archive.", "No Files Detected");
		
		if (files)
			delete files;
		if (cmp)
			delete cmp;
		
		files = NULL;
		cmp = NULL;
		Game = NULL;
		*retROM = NULL;
		return (ROMType)0;
	}
	else if (files->size() == 1)
	{
		// One file is in the archive. Load it.
		selFile = &(*files->begin());
	}
	else
	{
#if !defined(GENS_UI_OPENEMU)
		// More than one file is in the archive. Load it.
		// TODO: Improve this!
		#if defined(GENS_UI_GTK)
			ZipSelectDialog *zip = new ZipSelectDialog(GTK_WINDOW(gens_window));
		#elif defined(GENS_UI_WIN32)
			ZipSelectDialog *zip = new ZipSelectDialog(Gens_hWnd);
		#else
			#error Can't determine UI.
		#endif
		selFile = zip->getFile(files);
		delete zip;
#endif
	}
	
	if (!selFile)
	{
		// No file was selected and/or Cancel was clicked.
		delete files;
		delete cmp;
		Game = NULL;
		*retROM = NULL;
		return (ROMType)0;
	}
	
	// Determine the ROM type.
	unsigned char detectBuf[2048];
	cmp->getFile(&(*selFile), detectBuf, sizeof(detectBuf));
	rtype = detectFormat(detectBuf);
	if (rtype < MD_ROM ||
	    rtype >= SegaCD_Image)
	{
		// Unknown ROM type, or this is a SegaCD image.
		delete files;
		delete cmp;
		Game = NULL;
		*retROM = NULL;
		return rtype;
	}
	
	// If the ROM is larger than 6MB (+512 bytes for SMD interleaving), don't load it.
	if (selFile->filesize > ((6 * 1024 * 1024) + 512))
	{
		GensUI::msgBox("ROM files larger than 6 MB are not supported.", "ROM File Error");
		delete files;
		delete cmp;
		Game = NULL;
		*retROM = NULL;
//.........这里部分代码省略.........
开发者ID:chipsoftwaretester,项目名称:OpenEmu,代码行数:101,代码来源:rom.cpp


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