使用zzip和minizip解压缩文件

摘要:
=NULL){delete[](p);(p)=NULL;};voidUnzipAndZip(constchar*pScrFileName,constchar*pDstFileName){structFILE_DESC{unsignedchar*pData;size_tDataSize;};std::map<std::string,FILE_ DESC>mapFileStreams;ZZIP_DIR*pZipDir=ZZIP_opendir(pScrFileName);ZZIP_方向*pZipDirent=空;while(pZipDirent=zzip_readdir(pZipDir)){size_tlength=strlen(pZipDirector->d_name);if(length>0){if(pZipDirect->d_name[length-1]!='\\'&&pZipDirent->d_name[length-1'!='/'){zzip_FILE*pZipFile=zzipfile_open!
#include <zzip/zzip.h>
#include
<zlib.h>
#include
<zip.h>
#include
<unzip.h>

#include
<string>
#include
<map>

#ifdef _DEBUG
#pragma comment( lib, "zlib_d.lib")
#pragma comment( lib, "zzip_d.lib")
#pragma comment( lib, "minizip_d.lib")
#else
#pragma comment( lib, "zlib.lib" )
#pragma comment( lib, "zzip.lib" )
#pragma comment( lib, "minizip.lib" )
#endif

#define SAFE_DELETEARRAY(p) if(p != NULL) { delete[] (p); (p) = NULL; };

void UnzipAndZip( const char* pScrFileName, const char* pDstFileName )
{
struct FILE_DESC
{
unsigned
char* pData;
size_t DataSize;
};

std::map
<std::string, FILE_DESC> mapFileStreams;

ZZIP_DIR
* pZipDir = zzip_opendir( pScrFileName );
ZZIP_DIRENT
* pZipDirent = NULL;
while( pZipDirent = zzip_readdir( pZipDir ) )
{
size_t length
= strlen(pZipDirent->d_name);
if( length > 0 )
{
if( pZipDirent->d_name[length - 1] != '\\' &&
pZipDirent
->d_name[length - 1] != '/' )
{
ZZIP_FILE
* pZipFile = zzip_file_open( pZipDir, pZipDirent->d_name, ZZIP_CASELESS );
if( pZipFile != NULL )
{
ZZIP_STAT sz;
memset(
&sz, 0, sizeof(sz) );
zzip_file_stat( pZipFile,
&sz );
if( sz.st_size > 0 )
{
unsigned
char* pBuffer = new unsigned char[sz.st_size];
zzip_file_read( pZipFile, pBuffer, sz.st_size );
FILE_DESC data
= { pBuffer, sz.st_size };
mapFileStreams[pZipDirent
->d_name] = data;
}
zzip_file_close( pZipFile );
}
}
}
}
if( pZipDir )
zzip_closedir( pZipDir );

zip_fileinfo ZipFileInfo;
zipFile ZipFile
= zipOpen( pDstFileName, 0 );

std::map
<std::string, FILE_DESC>::iterator iter =
mapFileStreams.begin();

while( iter != mapFileStreams.end() )
{
int err = zipOpenNewFileInZip( ZipFile, iter->first.c_str(),
&ZipFileInfo, NULL, 0, NULL, 0, NULL, 0, 0 );
zipWriteInFileInZip( ZipFile, iter
->second.pData, iter->second.DataSize );
SAFE_DELETEARRAY( iter
->second.pData );
++iter;
}
zipClose( ZipFile, NULL );
}

int main(int argc, char* argv[])
{
UnzipAndZip(
"test.zip", "dst.zip" );
return 0;
};

免责声明:文章转载自《使用zzip和minizip解压缩文件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Amoeba(变形虫)logicaldoc的外部认证——AD集成下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

OpenWrt上搭建纯L2TP服务器[ZT]

转移自:http://www.openwrt.pro/post-389.html纯L2TP(L2TP+ppp,无IPSec)首先安装xl2tpd软件包opkgupdateopkginstallxl2tpd edit/etc/xl2tpd/xl2tpd。conf,并配置l2tp服务器[global]port=1701authfile=/etc/xl2tpd/x...

Git安装配置(完整版)

/usr/bin/bashcd/var/www/aunsetGIT_DIRgitpulloriginmaster为您提供了另一个权限:chmod755/var/gitdata/a。git/books/post-receivechowngit:git/var/gitdata/a在git/hooks/post-receive模式下,客户端提交代码,服务器项目可以...

Spring Boot 核心配置文件 bootstrap &amp;amp; application

boostrap由父ApplicationContext加载,比applicaton优先加载boostrap里面的属性不能被覆盖3、bootstrap/application的应用场景application配置文件这个容易理解,主要用于SpringBoot项目的自动化配置。这个父级的SpringApplicationContext是先加载的,在加载appli...

oracle触发器调试

如果触发器执行成功,不会出现第4个图,不成功,会出现数据调试信息,具体报错位置会定位到。F7单步执行4.出错时,会出现调试数据,双击调试数据,可以复制出来...

Foxyproxy 火狐代理插件

Firefox上的插件Autoproxy一直很难使用。它永远不能更新规则,但foxyproxy可以替代它。用鼠标中键单击foxyproxy图标以在不同的代理方法之间切换。foxyproxy图标从foxhead变为蓝色,因为内容传输发生在网页中,该传输通过默认代理服务器,默认代理的初始颜色为蓝色。...

wifi密码暴力破解

转自:Python最新暴力破解WiFi,攻破所有密码限制,最强破解!...