blob: 7d27c9a93ced7fe0741cd87ba245b14e8a9ff8d8 (
plain)
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta id="repository-name" content="github.com/pablotron/zip-crystal">
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/doc.js"></script>
<title>README - github.com/pablotron/zip-crystal</title>
</head>
<body>
<div id="types-list">
<div id="search-box">
<input type="search" id="search-input" placeholder="Search...">
</div>
<ul>
<li class="current"><a href="index.html">README</a></li>
</ul>
<ul>
<li class="parent " data-id="github.com/pablotron/zip-crystal/Zip" data-name="zip">
<a href="Zip.html">Zip</a>
<ul>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Archive" data-name="zip::archive">
<a href="Zip/Archive.html">Archive</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/CompressionMethod" data-name="zip::compressionmethod">
<a href="Zip/CompressionMethod.html">CompressionMethod</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/DeflateCompressionHelper" data-name="zip::deflatecompressionhelper">
<a href="Zip/DeflateCompressionHelper.html">DeflateCompressionHelper</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Entry" data-name="zip::entry">
<a href="Zip/Entry.html">Entry</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Error" data-name="zip::error">
<a href="Zip/Error.html">Error</a>
</li>
<li class="parent " data-id="github.com/pablotron/zip-crystal/Zip/Extra" data-name="zip::extra">
<a href="Zip/Extra.html">Extra</a>
<ul>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Extra/Base" data-name="zip::extra::base">
<a href="Zip/Extra/Base.html">Base</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Extra/Zip64" data-name="zip::extra::zip64">
<a href="Zip/Extra/Zip64.html">Zip64</a>
</li>
</ul>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/GeneralFlags" data-name="zip::generalflags">
<a href="Zip/GeneralFlags.html">GeneralFlags</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/NoneCompressionHelper" data-name="zip::nonecompressionhelper">
<a href="Zip/NoneCompressionHelper.html">NoneCompressionHelper</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Source" data-name="zip::source">
<a href="Zip/Source.html">Source</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/TimeHelper" data-name="zip::timehelper">
<a href="Zip/TimeHelper.html">TimeHelper</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Version" data-name="zip::version">
<a href="Zip/Version.html">Version</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Writer" data-name="zip::writer">
<a href="Zip/Writer.html">Writer</a>
</li>
<li class="parent " data-id="github.com/pablotron/zip-crystal/Zip/Writers" data-name="zip::writers">
<a href="Zip/Writers.html">Writers</a>
<ul>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Writers/DirEntry" data-name="zip::writers::direntry">
<a href="Zip/Writers/DirEntry.html">DirEntry</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Writers/FileEntry" data-name="zip::writers::fileentry">
<a href="Zip/Writers/FileEntry.html">FileEntry</a>
</li>
<li class=" " data-id="github.com/pablotron/zip-crystal/Zip/Writers/WriterEntry" data-name="zip::writers::writerentry">
<a href="Zip/Writers/WriterEntry.html">WriterEntry</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div id="main-content">
<h1>zip-crystal</h1>
<p>Read and write zip archives natively from
<a href="http://crystal-lang.org/" target="_blank">Crystal</a>.</p>
<p><em>Features</em></p>
<ul><li>Read and write zip files</li><li>Native Crystal, no dependencies other than zlib</li><li>Stream writing (e.g. write zip to socket, pipe, or other arbitrary, non-seekable IO)</li><li>ZIP64 support</li><li>Store and DEFLATE compression</li><li>UTF-8 filename and comment support (EFS)</li></ul>
<p><em>TODO</em></p>
<ul><li>LZMA and BZip2 compression</li><li>Encryption (Legacy and Strong Encryption)</li><li>Split archives (e.g. multi-disk archives)</li><li>Legacy Unicode support</li></ul>
<h2>Installation</h2>
<p>Add this to your application's <code>shard.yml</code>:</p>
<pre><code class='language-yaml'>dependencies:
zip-crystal:
github: pablotron/zip-crystal</code></pre>
<h2>Usage</h2>
<pre><code class='language-crystal'><span class="k">require</span> <span class="s">"zip-crystal/zip"</span>
<span class="c"># write to "foo.zip"</span>
<span class="t">Zip</span>.write(<span class="s">"foo.zip"</span>) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span>
<span class="c"># add "bar.txt" with contents "hello!"</span>
zip.add(<span class="s">"bar.txt"</span>, <span class="s">"hello!"</span>)
<span class="c"># add local file "/path/to/image.png" as "image.png"</span>
zip.add_file(<span class="s">"image.png"</span>, <span class="s">"/path/to/image.png"</span>)
<span class="k">end</span>
<span class="c"># create memory io</span>
mem_io <span class="o">=</span> <span class="t">MemoryIO</span>.<span class="k">new</span>
<span class="c"># read from "foo.zip"</span>
<span class="t">Zip</span>.read(<span class="s">"foo.zip"</span>) <span class="k">do</span> <span class="o">|</span>zip<span class="o">|</span>
<span class="c"># extract "bar.txt" to mem_io</span>
zip[<span class="s">"bar.txt"</span>].write(mem_io)
<span class="c"># extract "image.png" to "output-image.png"</span>
zip[<span class="s">"image.png"</span>].write(<span class="s">"output-image.png"</span>)
<span class="k">end</span></code></pre>
<p>See the <a href="https://pablotron.github.com/zip-crystal/" target="_blank">API documentation</a>
for additional information.</p>
<h2>Contributing</h2>
<ol><li>Fork it ( https://github.com/pablotron/zip-crystal/fork )</li><li>Create your feature branch (git checkout -b my-new-feature)</li><li>Commit your changes (git commit -am 'Add some feature')</li><li>Push to the branch (git push origin my-new-feature)</li><li>Create a new Pull Request</li></ol>
<h2>Contributors</h2>
<ul><li><a href="https://github.com/pablotron" target="_blank">pablotron</a> Paul Duncan - creator, maintainer</li></ul>
</div>
</body>
</html>
|