1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5 <title>LuaZip: Reading files inside zip files
</title>
6 <link rel=
"stylesheet" href=
"http://www.keplerproject.org/doc.css" type=
"text/css"/>
7 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8"/>
14 <div id=
"product_logo">
15 <a href=
"http://www.keplerproject.org"><img alt=
"LuaZip logo" src=
"luazip-128.png"/></a>
17 <div id=
"product_name"><big><strong>LuaZip
</strong></big></div>
18 <div id=
"product_description">Reading files inside zip files
</div>
19 </div> <!-- id="product" -->
26 <li><a href=
"index.html">Home
</a>
28 <li><a href=
"index.html#overview">Overview
</a></li>
29 <li><a href=
"index.html#status">Status
</a></li>
30 <li><a href=
"index.html#download">Download
</a></li>
31 <li><a href=
"index.html#history">History
</a></li>
32 <li><a href=
"index.html#credits">Credits
</a></li>
33 <li><a href=
"index.html#contact">Contact
</a></li>
36 <li><a href=
"manual.html">Manual
</a>
38 <li><a href=
"manual.html#introduction">Introduction
</a></li>
39 <li><a href=
"manual.html#installation">Installation
</a></li>
40 <li><a href=
"manual.html#reference">Reference
</a></li>
43 <li><strong>Examples
</strong></li>
44 <li><a href=
"http://luaforge.net/projects/luazip/">Project
</a>
46 <li><a href=
"http://luaforge.net/tracker/?group_id=8">Bug Tracker
</a></li>
47 <li><a href=
"http://luaforge.net/scm/?group_id=8">CVS
</a></li>
50 <li><a href=
"license.html">License
</a></li>
52 </div> <!-- id="navigation" -->
57 <h2><a name=
"examples"></a>Example
</h2>
60 Suppose we have the following file hierarchy:
74 <li>c.zip contains the file 'd.txt'
</li>
75 <li>b2.ext2 is a zip file containing the file 'c2/d2.txt'
</li>
76 <li>a3.ext3 is a zip file containing the file 'b3/c3/d3.txt'
</li>
77 <li>luazip.zip contains the files 'luazip.h', 'luazip.c', 'Makefile', 'README'
</li>
80 Below is a small sample code displaying the basic use of the library.
85 local zfile, err = zip.open('luazip.zip')
87 -- print the filenames of the files inside the zip
88 for file in zfile:files() do
92 -- open README and print it
93 local f1, err = zfile:open('README')
94 local s1 = f1:read(
"*a")
100 -- open d.txt inside c.zip
101 local d, err = zip.openfile('a/b/c/d.txt')
105 -- open d2.txt inside b2.ext2
106 local d2, err = zip.openfile('a2/b2/c2/d2.txt',
"ext2")
110 -- open d3.txt inside a3.ext3
111 local d3, err = zip.openfile('a3/b3/c3/d3.txt', {
"ext2",
"ext3"})
116 </div> <!-- id="content" -->
118 </div> <!-- id="main" -->
121 <p><a href=
"http://validator.w3.org/check?uri=referer"><img src=
"http://www.w3.org/Icons/valid-xhtml10" alt=
"Valid XHTML 1.0!" height=
"31" width=
"88" /></a></p>
123 $Id: examples.html,v
1.4 2006/
03/
23 20:
45:
21 carregal Exp $
125 </div> <!-- id="about" -->
127 </div> <!-- id="container" -->