<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>iPhoneGeek 爱疯极客 &#187; 压缩解压</title>
	<atom:link href="http://www.iphone-geek.cn/tag/%e5%8e%8b%e7%bc%a9%e8%a7%a3%e5%8e%8b/feed" rel="self" type="application/rss+xml" />
	<link>http://www.iphone-geek.cn</link>
	<description>iPhone 新闻，编程，技巧与提示，代码，教程</description>
	<lastBuildDate>Sun, 25 Jul 2010 13:49:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>跨平台代码分享之六 &#8211; 使用minizip进行解压</title>
		<link>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e8%b7%a8%e5%b9%b3%e5%8f%b0%e4%bb%a3%e7%a0%81%e5%88%86%e4%ba%ab%e4%b9%8b%e5%85%ad-%e4%bd%bf%e7%94%a8minizip%e8%bf%9b%e8%a1%8c%e8%a7%a3%e5%8e%8b</link>
		<comments>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e8%b7%a8%e5%b9%b3%e5%8f%b0%e4%bb%a3%e7%a0%81%e5%88%86%e4%ba%ab%e4%b9%8b%e5%85%ad-%e4%bd%bf%e7%94%a8minizip%e8%bf%9b%e8%a1%8c%e8%a7%a3%e5%8e%8b#comments</comments>
		<pubDate>Wed, 23 Dec 2009 10:56:03 +0000</pubDate>
		<dc:creator>bagusflyer</dc:creator>
				<category><![CDATA[基础]]></category>
		<category><![CDATA[编程]]></category>
		<category><![CDATA[跨平台]]></category>
		<category><![CDATA[压缩解压]]></category>

		<guid isPermaLink="false">http://www.iphone-geek.cn/?p=451</guid>
		<description><![CDATA[压缩和解压技术应用很广泛，比如游戏程序中的资源管理器可以使用压缩技术将许多文件打包，便于管理，也节约了空间。本文介绍使用minizip进行解压。由于可以使用zip工具比如winzip，betterzip等进行压缩，所以本文并未涉及压缩。
&#160;

minizip++
&#160;
我编写了一个简单的类，与minizip和zlib一起（实际上，Mac OSX中包括了zlib库，但其他平台不一定有zlib库，所以我将其包括在源码中），构成了minizip++。此类仅包含一个类zip::CReader，此类只包括一个函数openFile用于从zip文件中读取一个文件。
&#160;
范例概述
&#160;
本示例程序很简单，它从data.zip文件中提取data/hello.txt显示于屏幕上，有兴趣的话，你可以扩展此程序，从zip中提取图像然后显示出来。
&#160;
废话少说，下面介绍程序：

1. 先建立一个View based Xcode项目ziptest，再创建一个目录data，在此目录下建立一个文本文件hello.txt，编辑此文本文件，加入你想在屏幕上显示的内容，比如，我在hello.txt中加入“Hello World！”。压缩data目录，然后将压缩文件data.zip加入Xcode的resource。（注意：此时加入的zip文件将出现在Targets下的“Link Binary With Libraries”下，编译时会出现一个警告，zip文件将不会被加入到.app中。所以你应该将data.zip移动到&#8221;Copy Bundle Resources&#8221;下）

2. ziptestViewController.h部分如下：
12345@interface ziptestViewController : UIViewController &#123;
&#160; &#160; UILabel* _mytext;
&#125;

@property &#40;nonatomic,retain&#41; IBOutlet UILabel* _mytext;
3. 将ziptestViewController.m重命名为ziptestViewController.mm，部分代码如下：

4. 双击ziptestViewController.xib打开Interface Builder。添加一个Label。Control+点击File Owner拖动到新建的Label，选取_mytext。

5.然后加入header和library搜索路径。比如，我的Header Search Paths为：../../external/minizip++。然后按iphone项目使用静态库的最佳方法一文中介绍的方法加入ziptest项目。
6.在viewDidLoad下进入下列代码：
12345&#160; &#160; std::stringstream in;
&#160; &#160; zip::CReader reader;
&#160; &#160; NSString* zippath=&#91;&#91;&#91;NSBundle mainBundle&#93;resourcePath&#93;stringByAppendingPathComponent:@&#34;data.zip&#34;&#93;;
&#160; &#160; reader.openFile&#40;&#91;ziptestViewController getString:zippath&#93;,&#34;data/hello.txt&#34;,in&#41;;
&#160; &#160; _mytext.text = &#160;&#91;NSString stringWithCString:in.str&#40;&#41;.c_str&#40;&#41;&#93;;
6. 按Build and Go运行程序。
&#160;
minizip++中CReader类中用于解压的代码如下：
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970namespace zip
&#123;
&#160; &#160; 
&#160; &#160; void [...]]]></description>
			<content:encoded><![CDATA[<p>压缩和解压技术应用很广泛，比如游戏程序中的资源管理器可以使用压缩技术将许多文件打包，便于管理，也节约了空间。本文介绍使用minizip进行解压。由于可以使用zip工具比如winzip，betterzip等进行压缩，所以本文并未涉及压缩。</p>
<p>&nbsp;</p>
<p><span id="more-451"></span></p>
<h2>minizip++</h2>
<p>&nbsp;</p>
<p>我编写了一个简单的类，与minizip和zlib一起（实际上，Mac OSX中包括了zlib库，但其他平台不一定有zlib库，所以我将其包括在源码中），构成了minizip++。此类仅包含一个类zip::CReader，此类只包括一个函数openFile用于从zip文件中读取一个文件。</p>
<p>&nbsp;</p>
<h2>范例概述</h2>
<p>&nbsp;</p>
<p>本示例程序很简单，它从data.zip文件中提取data/hello.txt显示于屏幕上，有兴趣的话，你可以扩展此程序，从zip中提取图像然后显示出来。</p>
<p>&nbsp;</p>
<p>废话少说，下面介绍程序：</p>
<ul>
<li>1. 先建立一个View based Xcode项目ziptest，再创建一个目录data，在此目录下建立一个文本文件hello.txt，编辑此文本文件，加入你想在屏幕上显示的内容，比如，我在hello.txt中加入“Hello World！”。压缩data目录，然后将压缩文件data.zip加入Xcode的resource。（注意：此时加入的zip文件将出现在Targets下的“Link Binary With Libraries”下，编译时会出现一个警告，zip文件将不会被加入到.app中。所以你应该将data.zip移动到&#8221;Copy Bundle Resources&#8221;下）
</li>
<li>2. ziptestViewController.h部分如下：
<div class="codecolorer-container objc mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #a61390;">@interface</span> ziptestViewController <span style="color: #002200;">:</span> UIViewController <span style="color: #002200;">&#123;</span><br />
&nbsp; &nbsp; UILabel<span style="color: #002200;">*</span> _mytext;<br />
<span style="color: #002200;">&#125;</span><br />
<br />
<span style="color: #a61390;">@property</span> <span style="color: #002200;">&#40;</span>nonatomic,retain<span style="color: #002200;">&#41;</span> IBOutlet UILabel<span style="color: #002200;">*</span> _mytext;</div></td></tr></tbody></table></div>
<li>3. 将ziptestViewController.m重命名为ziptestViewController.mm，部分代码如下：
</li>
<li>4. 双击ziptestViewController.xib打开Interface Builder。添加一个Label。Control+点击File Owner拖动到新建的Label，选取_mytext。</li>
</li>
<li>5.然后加入header和library搜索路径。比如，我的Header Search Paths为：../../external/minizip++。然后按<a href="编程/iphone项目使用静态库的最佳方法">iphone项目使用静态库的最佳方法</a>一文中介绍的方法加入ziptest项目。</li>
<li>6.在viewDidLoad下进入下列代码：</li>
<div class="codecolorer-container objc mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="objc codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; std<span style="color: #002200;">::</span>stringstream <span style="color: #a61390;">in</span>;<br />
&nbsp; &nbsp; zip<span style="color: #002200;">::</span>CReader reader;<br />
&nbsp; &nbsp; <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a><span style="color: #002200;">*</span> zippath<span style="color: #002200;">=</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/"><span style="color: #400080;">NSBundle</span></a> mainBundle<span style="color: #002200;">&#93;</span>resourcePath<span style="color: #002200;">&#93;</span>stringByAppendingPathComponent<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;data.zip&quot;</span><span style="color: #002200;">&#93;</span>;<br />
&nbsp; &nbsp; reader.openFile<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#91;</span>ziptestViewController getString<span style="color: #002200;">:</span>zippath<span style="color: #002200;">&#93;</span>,<span style="color: #bf1d1a;">&quot;data/hello.txt&quot;</span>,<span style="color: #a61390;">in</span><span style="color: #002200;">&#41;</span>;<br />
&nbsp; &nbsp; _mytext.text <span style="color: #002200;">=</span> &nbsp;<span style="color: #002200;">&#91;</span><a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/"><span style="color: #400080;">NSString</span></a> stringWithCString<span style="color: #002200;">:</span><span style="color: #a61390;">in</span>.str<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span>.c_str<span style="color: #002200;">&#40;</span><span style="color: #002200;">&#41;</span><span style="color: #002200;">&#93;</span>;</div></td></tr></tbody></table></div>
<li>6. 按Build and Go运行程序。</li>
<p>&nbsp;</p>
<p>minizip++中CReader类中用于解压的代码如下：</p>
<div class="codecolorer-container cpp mac-classic" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br /></div></td><td><div class="cpp codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000ff;">namespace</span> zip<br />
<span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #0000ff;">void</span> CReader<span style="color: #008080;">::</span><span style="color: #007788;">openFile</span><span style="color: #008000;">&#40;</span><span style="color: #0000ff;">const</span> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span><span style="color: #000040;">&amp;</span> zip,<span style="color: #0000ff;">const</span> std<span style="color: #008080;">::</span><span style="color: #007788;">string</span><span style="color: #000040;">&amp;</span> file,std<span style="color: #008080;">::</span><span style="color: #007788;">iostream</span><span style="color: #000040;">&amp;</span> in<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; unzFile uf<span style="color: #000080;">=</span><span style="color: #0000ff;">NULL</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// open zip file</span><br />
<span style="color: #339900;">#ifdef USEWIN32IOAPI</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;zlib_filefunc_def ffunc<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fill_win32_filefunc<span style="color: #008000;">&#40;</span><span style="color: #000040;">&amp;</span>ffunc<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;uf <span style="color: #000080;">=</span> unzOpen2<span style="color: #008000;">&#40;</span>zip.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>,<span style="color: #000040;">&amp;</span>ffunc<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#else</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; uf <span style="color: #000080;">=</span> unzOpen<span style="color: #008000;">&#40;</span>zip.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
<span style="color: #339900;">#endif</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>uf<span style="color: #000080;">==</span><span style="color: #0000ff;">NULL</span><span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;No zip file found!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// find the file inside zip &nbsp; &nbsp; </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> unzLocateFile<span style="color: #008000;">&#40;</span>uf,file.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>,0<span style="color: #008000;">&#41;</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> UNZ_OK <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;%s not found in zip<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,file.<span style="color: #007788;">c_str</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// file founded,extract it into the stream</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// open it </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> unzOpenCurrentFile<span style="color: #008000;">&#40;</span>uf<span style="color: #008000;">&#41;</span> <span style="color: #000040;">!</span><span style="color: #000080;">=</span> UNZ_OK <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// TODO: error handling</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;unzOpenCurrentFile error<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// get the file info</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">char</span> filename_inzip<span style="color: #008000;">&#91;</span>256<span style="color: #008000;">&#93;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">int</span> err<span style="color: #000080;">=</span>UNZ_OK<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; unz_file_info file_info<span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; err <span style="color: #000080;">=</span> unzGetCurrentFileInfo<span style="color: #008000;">&#40;</span>uf,<span style="color: #000040;">&amp;</span>file_info,filename_inzip,<span style="color: #0000dd;">sizeof</span><span style="color: #008000;">&#40;</span>filename_inzip<span style="color: #008000;">&#41;</span>,<span style="color: #0000ff;">NULL</span>,0,<span style="color: #0000ff;">NULL</span>,0<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span>err<span style="color: #000040;">!</span><span style="color: #000080;">=</span>UNZ_OK<span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// TODO: error handling</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;error %d with zipfile in unzGetCurrentFileInfo<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>,err<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// read the file into stream</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">char</span><span style="color: #000040;">*</span> buf <span style="color: #000080;">=</span> <span style="color: #008000;">&#40;</span><span style="color: #0000ff;">char</span><span style="color: #000040;">*</span><span style="color: #008000;">&#41;</span><span style="color: #0000dd;">malloc</span><span style="color: #008000;">&#40;</span>file_info.<span style="color: #007788;">uncompressed_size</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">if</span> <span style="color: #008000;">&#40;</span> unzReadCurrentFile<span style="color: #008000;">&#40;</span>uf,buf,file_info.<span style="color: #007788;">uncompressed_size</span><span style="color: #008000;">&#41;</span> <span style="color: #000080;">&lt;</span> <span style="color: #0000dd;">0</span> <span style="color: #008000;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// TODO: error handling</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">printf</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">&quot;error in unzReadCurrentFile!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">free</span><span style="color: #008000;">&#40;</span>buf<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">return</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666;">// write to istream</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; in.<span style="color: #007788;">rdbuf</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #000040;">-</span><span style="color: #000080;">&gt;</span>sputn<span style="color: #008000;">&#40;</span>buf,file_info.<span style="color: #007788;">uncompressed_size</span><span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">free</span><span style="color: #008000;">&#40;</span>buf<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; unzCloseCurrentFile<span style="color: #008000;">&#40;</span>uf<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; unzClose<span style="color: #008000;">&#40;</span>uf<span style="color: #008000;">&#41;</span><span style="color: #008080;">;</span><br />
&nbsp; &nbsp; <span style="color: #008000;">&#125;</span><br />
<span style="color: #008000;">&#125;</span></div></td></tr></tbody></table></div>
<p>&nbsp;</p>
<h2><strong>源码下载</strong></h2>
<p>&nbsp;</p>
<p><a href='http://www.iphone-geek.cn/wp-content/uploads/2009/12/ziptest.zip'>ziptest</a></p>
<p>&nbsp;</p>
<p>注意：编译时，你需要修改头文件路径或者按照我的路径解压源代码。我的路径如下：</p>
<p>&nbsp;</p>
<p><quoteblock><br />
root<br />
  |&#8212;&#8212; external<br />
                 |&#8212;&#8212;&#8212;&#8211; minizip++</p>
<p>  |&#8212;&#8212; test<br />
                 |&#8212;&#8212;&#8212;&#8211; ziptest<br />
</quoteblock></p>
<p>&nbsp;</p>
<p><a href='http://www.iphone-geek.cn/wp-content/uploads/2009/12/minizip++.zip'>minizip++</a></p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.iphone-geek.cn/%e7%bc%96%e7%a8%8b/%e8%b7%a8%e5%b9%b3%e5%8f%b0%e4%bb%a3%e7%a0%81%e5%88%86%e4%ba%ab%e4%b9%8b%e5%85%ad-%e4%bd%bf%e7%94%a8minizip%e8%bf%9b%e8%a1%8c%e8%a7%a3%e5%8e%8b/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
