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