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


C++ ZipFile::GetFilename方法代码示例

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


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

示例1: Load

bool TextureHandler::Load (const char *zip) 
{
	FILE *f = fopen (zip, "rb");

	if (f) {
		ZipFile *zf = new ZipFile;
		if (zf->Init (f) == RET_FAIL) {
			logger.Trace (NL_Error, "Failed to load zip archive %s\n", zip);
			fclose (f);
			return false;
		}

		const char *imgExt[]={ "bmp", "jpg", "tga", "png", "dds", "pcx", "pic", "gif", "ico", 0 };

		// Add the zip entries to the texture set
		for (int a=0;a<zf->GetNumFiles ();a++)
		{
			char tempFile[64];
			zf->GetFilename (a, tempFile, sizeof(tempFile));

			char *ext=FixTextureName (tempFile);
			if (ext)
			{
				int x=0;
				for (x=0;imgExt[x];x++)
					if (!strcmp(imgExt[x],ext)) break;

				if (!imgExt[x])
					continue;

				if (textures.find(tempFile) != textures.end())
					continue;

				TexRef ref;
				ref.zip = zips.size();
				ref.index = a;
				ref.texture = LoadTexture (zf,a, tempFile);

				if(textures.find(tempFile)!=textures.end())
					logger.Trace(NL_Debug,"Texture %s already loaded\n", tempFile);

				TexRef &tr = textures[tempFile];
				tr.texture = ref.texture;
				tr.index = a;;
				tr.zip = zips.size();
			}
		}

		fclose (f);

		zips.push_back (zf);
	}

	return false;
}
开发者ID:SpliFF,项目名称:upspring,代码行数:55,代码来源:Texture.cpp

示例2: LoadImages

void Tools::LoadImages()
{
	FILE *f = fopen("data/data.ups", "rb");
	if (!f) {
		fltk::message("Failed to load data.ups");
	}
	else
	{
		ZipFile zf;
		zf.Init(f);

		for(unsigned int a=0;a<tools.size();a++) {
			if (!tools[a]->imageFile)
				continue;

			std::string fn = tools[a]->imageFile;

			int zipIndex=-1;
			for (int fi=0;fi<zf.GetNumFiles();fi++) {
				char zfn [64];
				zf.GetFilename(fi, zfn, sizeof(zfn));
				if (!STRCASECMP(zfn, fn.c_str())) {
					zipIndex = fi;
					break;
				}
			}

			if (zipIndex>=0) {
				int len = zf.GetFileLen(zipIndex);
				char *buf = new char[len];
				zf.ReadFile(zipIndex, buf);

				tools[a]->image = FltkImage::Load(buf, len);
				if (!tools[a]->image) {
					fltk::message("Failed to load texture %s\n", fn.c_str());
					delete[] buf;
					continue;
				}
				delete[] buf;

				tools[a]->button->image(tools[a]->image->img);
				tools[a]->button->label("");
			} else
				fltk::message("Couldn't find %s", fn.c_str());
		}
		fclose(f);
	}
}
开发者ID:Neoniet,项目名称:upspring,代码行数:48,代码来源:Tools.cpp


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