解压
2013-10-23 11:37
190 查看
std::string curentPath=CCFileUtils::sharedFileUtils()->getWriteablePath();
std::string canWriteString=CCFileUtils::sharedFileUtils()->getWriteablePath()+"mac.zip";
CCFileUtils::sharedFileUtils()->getWriteablePath();
unzFile cUnzFile;
unz_global_info cGlobalInfo;
unz_file_info cFileInRo={0};
unsigned char buffer[4096] = {0};
//开始解压
cUnzFile = unzOpen( canWriteString.c_str()) ;
if ( cUnzFile == NULL )
{
CCLOG("文件不存在 你自己先去看看这个到底在不在!");
}
if ( UNZ_OK != unzGetGlobalInfo( cUnzFile , &cGlobalInfo ) )
{
CCLOG("获取整个zip文档详情 错误!");
}
for ( int i = 0 ; i < cGlobalInfo.number_entry ; i++ )
{
if ( UNZ_OK != unzGetCurrentFileInfo(cUnzFile , &cFileInRo ,
NULL, (uLong)0,
NULL , (uLong)0 ,
NULL , (uLong)0) )
{
CCLOG("获取整个zip文档中某个文档信息 错误!");
}
char* filename = (char*) malloc(cFileInRo.size_filename +1 );
unzGetCurrentFileInfo(cUnzFile, &cFileInRo, filename, cFileInRo.size_filename + 1, NULL, 0, NULL, 0);
filename[cFileInRo.size_filename] = '\0';
if ( UNZ_OK != unzOpenCurrentFile( cUnzFile ) )
{
}
FILE* fp = fopen((curentPath+filename).c_str(), "wb");
while( fp)
{
int len = unzReadCurrentFile(cUnzFile , (voidp)buffer, 4096) ;
if( len > 0 )
{
fwrite(buffer,sizeof(char),len,fp);
}
else if( read<=0 )
{
CCLOG("读取文档内容错误!");
break;
}
else
{
break;
}
}
if(fp)
{
fclose( fp );
}
delete filename;
CCLOG("outString %s",filename);
unzCloseCurrentFile( cUnzFile );
unzGoToNextFile( cUnzFile );
}
unzClose( cUnzFile ) ;
cout << "完了" << endl ;
std::string canWriteString=CCFileUtils::sharedFileUtils()->getWriteablePath()+"mac.zip";
CCFileUtils::sharedFileUtils()->getWriteablePath();
unzFile cUnzFile;
unz_global_info cGlobalInfo;
unz_file_info cFileInRo={0};
unsigned char buffer[4096] = {0};
//开始解压
cUnzFile = unzOpen( canWriteString.c_str()) ;
if ( cUnzFile == NULL )
{
CCLOG("文件不存在 你自己先去看看这个到底在不在!");
}
if ( UNZ_OK != unzGetGlobalInfo( cUnzFile , &cGlobalInfo ) )
{
CCLOG("获取整个zip文档详情 错误!");
}
for ( int i = 0 ; i < cGlobalInfo.number_entry ; i++ )
{
if ( UNZ_OK != unzGetCurrentFileInfo(cUnzFile , &cFileInRo ,
NULL, (uLong)0,
NULL , (uLong)0 ,
NULL , (uLong)0) )
{
CCLOG("获取整个zip文档中某个文档信息 错误!");
}
char* filename = (char*) malloc(cFileInRo.size_filename +1 );
unzGetCurrentFileInfo(cUnzFile, &cFileInRo, filename, cFileInRo.size_filename + 1, NULL, 0, NULL, 0);
filename[cFileInRo.size_filename] = '\0';
if ( UNZ_OK != unzOpenCurrentFile( cUnzFile ) )
{
}
FILE* fp = fopen((curentPath+filename).c_str(), "wb");
while( fp)
{
int len = unzReadCurrentFile(cUnzFile , (voidp)buffer, 4096) ;
if( len > 0 )
{
fwrite(buffer,sizeof(char),len,fp);
}
else if( read<=0 )
{
CCLOG("读取文档内容错误!");
break;
}
else
{
break;
}
}
if(fp)
{
fclose( fp );
}
delete filename;
CCLOG("outString %s",filename);
unzCloseCurrentFile( cUnzFile );
unzGoToNextFile( cUnzFile );
}
unzClose( cUnzFile ) ;
cout << "完了" << endl ;
相关文章推荐
- 菜鸟 之 web.xml常用元素
- showmodalDialog的基本使用(转载)
- 创建任务需要大量的图形和设计和生产工作
- C++中.h与.cpp的关系
- 主从复制 Last_SQL_Errno: 1666
- 你知道德迅投资?想知道德迅投资吗?
- LUA CJSON配置方式
- Photoshop打造出一朵华丽的彩色水晶花朵
- 域功能级别与林功能级别的功能
- C++操作符重载
- Unity3D插件之Easy Touch 3.1(1): Easy Joystick
- 一道面试题
- Android4.2 使preinstall中的所有应用正常显示在launcher的默认布局中
- C# 的三种序列化方法
- opencv 2.4+ c++ svm介绍
- 软件项目版本号的命名规则及格式
- 网页开发的6种在线调试环境
- Sac lancel french flair sont souvent prendre en considération un luxe raisonnable simplement en quelques-uns
- sqlite中常见的问题总结
- [Android面试题-12] 经典Android面试题和答案[答案修正版]