-
Notifications
You must be signed in to change notification settings - Fork 1
/
minizip.html
177 lines (170 loc) · 10.1 KB
/
minizip.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title> minizip - ZIP reader & writer </title>
<script src="jquery.js"></script>
<script src="jquery-cookie.js"></script>
<script src="jquery-tablesorter.js"></script>
<script src="strftime.js"></script>
<script src="mustache.js"></script>
<script src="config.js"></script>
<script src="main.js"></script>
<link rel="stylesheet" type="text/css" href="templates/reset.css" />
<link rel="stylesheet" type="text/css" href="templates/hack.css" />
<link rel="stylesheet" type="text/css" id="lights_css" />
<script>
var DOCNAME = 'minizip'
var PROJECT = 'minizip'
//set the lights before rendering starts
set_lights()
</script>
</head>
<body>
<header>
<div class="container">
<div class="btn-container btn-lights-container">
<a href="#" class="btn btn-lights" id="lights">lights</a>
</div>
<div class="btn-container btn-home-container">
<a href="/" class="btn btn-home">luapower</a>
</div>
<table id="header_table">
<tr>
<td style="vertical-align: middle;" width="100%">
<h1> minizip </h1>
<h2> ZIP reader & writer </h2>
</td>
<td style="vertical-align: middle;" align="right" style="height: 150px">
<table><tr><td>
<div class="doc" id="package_info_container">
<div id="package_info"> </div>
<div id="commit_log"> </div>
</div>
<a href="https://github.com/luapower/minizip" class="btn btn-rightside btn-github"><span class="icon"></span>View on GitHub</a>
</td></tr><tr><td>
<a href="https://github.com/luapower/minizip/tarball/master" class="btn btn-rightside">Download as .tar.gz</a>
</td></tr><tr><td>
<a href="https://github.com/luapower/minizip/zipball/master" class="btn btn-rightside">Download as .zip</a>
</td></tr></table>
</td>
</tr>
</table>
<div class="btn-container btn-discuss-container">
<a href="https://github.com/luapower/minizip/issues/new" target="_blank"
class="btn btn-rightside btn-discuss"><span class="icon"></span>Discuss</a>
</div>
</div>
</header>
<div class="bg-container">
<div class="bg-center-container">
<div class="bg bg-minizip" style="background-image: url('bg/minizip.png');"></div>
</div>
</div>
<div class="under-header">
<div class="container">
<div id="toc_container" class="toc_container doc"></div>
<button id=tab1_button class="tab_button hidden">Documentation</button>
<button id=tab2_button class="tab_button hidden">Package Info</button>
<div id="tabs_cointainer">
<div id="tab1_container">
<section class="doc">
<span id="module_info"></span>
<h2 id="local-zip-requireminizip"><code>local zip = require'minizip'</code></h2>
<p>Supports creating, reading, writing, appending, and listing a ZIP file. Advanced use of this module requires an understanding of the <a href="http://www.pkware.com/documents/casestudies/APPNOTE.TXT">ZIP file format</a>.</p>
<h2 id="features">Features</h2>
<ul>
<li>encryption and decryption with a password</li>
<li>reading and writing of large (> 4G) files</li>
<li>copying files between two zip files without decompression/compression steps</li>
</ul>
<h2 id="zip.openfilename-mode---z"><code>zip.open(filename[, mode]) -> z</code></h2>
<p>Opens a ZIP file for reading or writing, depending on the mode argument:</p>
<ul>
<li><code>"r"</code> - open for reading (listing and decompressing an existing ZIP archive)</li>
<li><code>"w"</code> - open for writing (creating a new ZIP archive)</li>
<li><code>"a"</code> - open for appending (adding more files to an existing archive)</li>
</ul>
<p>If the file is opened for reading, only the reading methods are available in the zip object, and similarly, if the file was opened for writing, only the writing methods are available. Deleting files is not supported, but see <code>z:copy_from_zip()</code>.</p>
<h2 id="zcloseglobal_comment"><code>z:close([global_comment])</code></h2>
<p>Close the ZIP file. If the file was opened for writing, a global comment can also be specified.</p>
<h2 id="zadd_filefilename-options_t"><code>z:add_file(filename | options_t)</code></h2>
<p>Add a new file to a ZIP archive that was opened for writing, and set it as the current file. After this, you can write the file contents with <code>z:write()</code> and finally close it with <code>z:close_file()</code> (or <code>z:close_file_raw()</code> if opened in raw mode). Options can be specified with <code>options_t</code>:</p>
<ul>
<li><code>filename</code> - the path and file name - to add an empty directory, suffix the name with a slash (<code>/</code>) character</li>
<li><code>date</code> - an optional file date in <code>os.date'*t'</code> format</li>
<li><code>comment</code> - an optional comment string</li>
<li><code>password</code> - an optional password string to encrypt the file with</li>
<li><code>raw</code> - raw mode (boolean); in this mode:
<ul>
<li><code>method</code> must also be set to indicate the compression method used (zee zlib spec for details)</li>
<li><code>z:write()</code> must be used to write data in compressed form</li>
<li>the file must be closed with <code>z:close_file_raw()</code> to which you must pass the uncompressed file size and the CRC checksum, or you'll get an invalid ZIP file.</li>
</ul></li>
<li><code>zip64</code> - (boolean); enable support for files larger than 4G (disabled by default because the default <code>zip</code> and <code>unzip</code> unix commands doesn't support it)</li>
</ul>
<p>There are other options which require an understanding of the ZIP file format to be used. See the source code for the full list and the description and default value of each.</p>
<h2 id="zwrites"><code>z:write(s)</code></h2>
<p>Append a string to the current file contents.</p>
<h2 id="zclose_file"><code>z:close_file()</code></h2>
<p>Close the current file.</p>
<h2 id="zclose_file_rawuncompressed_size-crc"><code>z:close_file_raw(uncompressed_size, crc)</code></h2>
<p>Close the current file that was opened in raw mode with <code>z:add_file()</code>.</p>
<h2 id="zarchiveoptions_t-data-size"><code>z:archive(options_t, data[, size])</code></h2>
<p>Add a new file to the archive (shortcut for the sequence <code>z:add_file()</code>, <code>z:write()</code>, <code>z:close_file()</code>).</p>
<h2 id="zcopy_from_zipz-buf_size"><code>z:copy_from_zip(z[, buf_size])</code></h2>
<p>Copy the current file from a zip object that was opened for reading, into the <code>self</code> zip object which it was opened for writing. The file is copied in <code>raw</code> mode to avoid decompressing and compressing back the data. This can be used to implement deleting files from a ZIP archive. <code>buf_size</code> is the size of the buffer used for transferring the data (defaults to 4096).</p>
<h2 id="zget_global_info"><code>z:get_global_info()</code></h2>
<p>Return a table containing global info for a ZIP file that was opened for reading.</p>
<h2 id="zfirst_file"><code>z:first_file()</code></h2>
<p>Set the first file in the ZIP catalog as the current file.</p>
<h2 id="znext_file"><code>z:next_file()</code></h2>
<p>Set the next file in the ZIP catalog as the current file.</p>
<h2 id="zlocate_filefilename-case_insensitive---true-false"><code>z:locate_file(filename[, case_insensitive]) -> true | false</code></h2>
<p>Locate a file in the ZIP catalog by name and if found, set it as the current file. Return true if found, false if not.</p>
<h2 id="zget_file_pos---zpos"><code>z:get_file_pos() -> zpos</code></h2>
<p>Get an object representing the position of the current file in the ZIP catalog that can be later used to set the current file to.</p>
<h2 id="zgoto_file_poszpos"><code>z:goto_file_pos(zpos)</code></h2>
<p>Set the current file to <code>zpos</code>.</p>
<h2 id="zget_file_info---info_t"><code>z:get_file_info() -> info_t</code></h2>
<p>Return a table that contains information about the current file such as filename, uncompressed size and date.</p>
<h2 id="zopen_filepassword"><code>z:open_file([password])</code></h2>
<p>Open the current file for reading, optionally specifying a password if the file is encrypted. After opening, call <code>z:read_cdata()</code> to read the file contents, and <code>z:close_file()</code> to close the file so you can open another one.</p>
<h2 id="zread_cdatabuf-size---size"><code>z:read_cdata(buf, size) -> size</code></h2>
<p>Read more bytes from the currently opened file into a buffer. Return the number of bytes actually read.</p>
<h2 id="zreadsize---s"><code>z:read(size) -> s</code></h2>
<p>Read more bytes from the currently opened file into a string.</p>
<h2 id="ztell---n"><code>z:tell() -> n</code></h2>
<p>Return the current position in uncompressed data.</p>
<h2 id="zeof---true-false"><code>z:eof() -> true | false</code></h2>
<p>Check for EOF in current file opened for reading.</p>
<h2 id="zget_offset---n"><code>z:get_offset() -> n</code></h2>
<p>Get the current file offset.</p>
<h2 id="zset_offsetn"><code>z:set_offset(n)</code></h2>
<p>Set the current file offset.</p>
<h2 id="zfiles---iterator---info_t"><code>z:files() -> iterator() -> info_t</code></h2>
<p>List files in archive, returning the file info table for each file. On each iteration, the file is set as the current file so <code>z:open_file()</code> can be used to read the file contents.</p>
<h2 id="zextractfilepath---s"><code>z:extract(filepath) -> s</code></h2>
<p>Extract a file from the ZIP archive and return its contents as a string. This is a shortcut for the sequence <code>z:open_file()</code>, <code>z:read()</code>, <code>z:close_file()</code>.</p>
</section>
</div>
<div id="tab2_container" class="doc"></div>
</div>
</div>
<div class="container">
<footer>
<div id="disqus_thread"></div>
<div class="faint">[email protected] | <a href="http://unlicense.org/">public domain</a></div>
</footer>
</div>
</div>
<script type="text/x-mustache" id=info_tab_template>
<h3>Modules</h3>
<ul>
{{#module_array}}
<li>{{name}}</li>
{{/module_array}}
</ul>
</script>
</body>
</html>