summaryrefslogtreecommitdiff
path: root/Zip/Writer.html
diff options
context:
space:
mode:
Diffstat (limited to 'Zip/Writer.html')
-rw-r--r--Zip/Writer.html389
1 files changed, 389 insertions, 0 deletions
diff --git a/Zip/Writer.html b/Zip/Writer.html
new file mode 100644
index 0000000..c28c13e
--- /dev/null
+++ b/Zip/Writer.html
@@ -0,0 +1,389 @@
+<!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>Zip::Writer - 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><a href="../index.html">README</a></li>
+ </ul>
+
+ <ul>
+
+ <li class="parent open current" 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=" " data-id="github.com/pablotron/zip-crystal/Zip/Extra" data-name="zip::extra">
+ <a href="../Zip/Extra.html">Extra</a>
+
+ </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=" current" data-id="github.com/pablotron/zip-crystal/Zip/Writer" data-name="zip::writer">
+ <a href="../Zip/Writer.html">Writer</a>
+
+ </li>
+
+ <li class=" " data-id="github.com/pablotron/zip-crystal/Zip/WriterEntry" data-name="zip::writerentry">
+ <a href="../Zip/WriterEntry.html">WriterEntry</a>
+
+ </li>
+
+</ul>
+
+
+ </li>
+
+</ul>
+
+</div>
+
+<div id="main-content">
+<h1 class="type-name">
+
+ <span class="kind">class</span> Zip::Writer
+
+</h1>
+
+
+ <ul class="superclass-hierarchy"><li class="superclass"><a href="../Zip/Writer.html">Zip::Writer</a></li><li class="superclass">Reference</li><li class="superclass">Object</li></ul>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <h2>Defined in:</h2>
+
+
+
+
+
+
+ <h2>Class Method Summary</h2>
+ <ul class="list-summary">
+
+ <li class="entry-summary">
+ <a href="#new%28io%3AIO%2Cpos%3AUInt32%3D%3Cspanclass%3D%22n%22%3E0%3C%2Fspan%3E%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%2Cversion%3AVersion%3D%3Cspanclass%3D%22t%22%3EVersion%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFAULT%3C%2Fspan%3E%29-class-method" class="signature"><strong>.new</strong>(io : IO, pos : UInt32 = <span class="n">0</span>, comment : String = <span class="s">&quot;&quot;</span>, version : Version = <span class="t">Version</span><span class="t">::</span><span class="t">DEFAULT</span>)</a>
+
+ <div class="summary"><p>Create a new <code><a href="../Zip/Writer.html">Writer</a></code> object.</p></div>
+
+ </li>
+
+ </ul>
+
+
+
+ <h2>Instance Method Summary</h2>
+ <ul class="list-summary">
+
+ <li class="entry-summary">
+ <a href="#add%28path%3AString%2Cio%3AIO%2Cmethod%3ACompressionMethod%3D%3Cspanclass%3D%22t%22%3ECompressionMethod%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFLATE%3C%2Fspan%3E%2Ctime%3ATime%3D%3Cspanclass%3D%22t%22%3ETime%3C%2Fspan%3E.now%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%29%3AUInt32-instance-method" class="signature"><strong>#add</strong>(path : String, io : IO, method : CompressionMethod = <span class="t">CompressionMethod</span><span class="t">::</span><span class="t">DEFLATE</span>, time : Time = <span class="t">Time</span>.now, comment : String = <span class="s">&quot;&quot;</span>) : UInt32</a>
+
+ <div class="summary"><p>Read data from <code>IO</code> <em>io</em>, write it to <em>path</em> in archive, then return the number of bytes written.</p></div>
+
+ </li>
+
+ <li class="entry-summary">
+ <a href="#add%28path%3AString%2Cdata%3AString%7CBytes%2Cmethod%3ACompressionMethod%3D%3Cspanclass%3D%22t%22%3ECompressionMethod%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFLATE%3C%2Fspan%3E%2Ctime%3ATime%3D%3Cspanclass%3D%22t%22%3ETime%3C%2Fspan%3E.now%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%29%3AUInt32-instance-method" class="signature"><strong>#add</strong>(path : String, data : String | Bytes, method : CompressionMethod = <span class="t">CompressionMethod</span><span class="t">::</span><span class="t">DEFLATE</span>, time : Time = <span class="t">Time</span>.now, comment : String = <span class="s">&quot;&quot;</span>) : UInt32</a>
+
+ <div class="summary"><p>Write <em>data</em> to <em>path</em> in archive and return number of bytes written.</p></div>
+
+ </li>
+
+ <li class="entry-summary">
+ <a href="#add_file%28path%3AString%2Cfile_path%3AString%2Cmethod%3ACompressionMethod%3D%3Cspanclass%3D%22t%22%3ECompressionMethod%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFLATE%3C%2Fspan%3E%2Ctime%3ATime%3D%3Cspanclass%3D%22t%22%3ETime%3C%2Fspan%3E.now%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%29%3AUInt32-instance-method" class="signature"><strong>#add_file</strong>(path : String, file_path : String, method : CompressionMethod = <span class="t">CompressionMethod</span><span class="t">::</span><span class="t">DEFLATE</span>, time : Time = <span class="t">Time</span>.now, comment : String = <span class="s">&quot;&quot;</span>) : UInt32</a>
+
+ <div class="summary"><p>Add local file <em>file_path</em> to archive as <em>path</em> and return number of bytes written.</p></div>
+
+ </li>
+
+ <li class="entry-summary">
+ <a href="#bytes_written%3AUInt32-instance-method" class="signature"><strong>#bytes_written</strong> : UInt32</a>
+
+ <div class="summary"><p>Return the total number of bytes written so far.</p></div>
+
+ </li>
+
+ <li class="entry-summary">
+ <a href="#close-instance-method" class="signature"><strong>#close</strong></a>
+
+ <div class="summary"><p>Close this writer and return the total number of bytes written.</p></div>
+
+ </li>
+
+ <li class="entry-summary">
+ <a href="#closed%3F%3ABool-instance-method" class="signature"><strong>#closed?</strong> : Bool</a>
+
+ <div class="summary"><p>Is this <code><a href="../Zip/Writer.html">Writer</a></code> closed? </p></div>
+
+ </li>
+
+ </ul>
+
+
+
+
+
+<div class="methods-inherited">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+</div>
+
+
+ <h2>Class Method Detail</h2>
+
+ <div class="entry-detail" id="new&#40;io:IO,pos:UInt32&#61;&lt;spanclass&#61;&quot;n&quot;&gt;0&lt;/span&gt;,comment:String&#61;&lt;spanclass&#61;&quot;s&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;,version:Version&#61;&lt;spanclass&#61;&quot;t&quot;&gt;Version&lt;/span&gt;&lt;spanclass&#61;&quot;t&quot;&gt;::&lt;/span&gt;&lt;spanclass&#61;&quot;t&quot;&gt;DEFAULT&lt;/span&gt;&#41;-class-method">
+ <div class="signature">
+
+ def self.<strong>new</strong>(io : IO, pos : UInt32 = <span class="n">0</span>, comment : String = <span class="s">&quot;&quot;</span>, version : <a href="../Zip/Version.html">Version</a> = <span class="t">Version</span><span class="t">::</span><span class="t">DEFAULT</span>)
+
+ <a class="method-permalink" href="#new%28io%3AIO%2Cpos%3AUInt32%3D%3Cspanclass%3D%22n%22%3E0%3C%2Fspan%3E%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%2Cversion%3AVersion%3D%3Cspanclass%3D%22t%22%3EVersion%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFAULT%3C%2Fspan%3E%29-class-method">#</a>
+ </div>
+
+ <div class="doc"><p>Create a new <code><a href="../Zip/Writer.html">Writer</a></code> object.</p>
+
+<p>You shouldn't need to instantiate this class directly; use
+<code><a href="../Zip.html#write%28io%3AIO%2Cpos%3AUInt32%3D%3Cspanclass%3D%22n%22%3E0_u32%3C%2Fspan%3E%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%2Cversion%3AVersion%3D%3Cspanclass%3D%22t%22%3EVersion%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFAULT%3C%2Fspan%3E%2C%26cb%3AWriter-%3E%29%3AUInt32-class-method">Zip.write</a>()</code> instead.</p></div>
+
+ <br/>
+ <div>
+
+ </div>
+ </div>
+
+
+
+
+ <h2>Instance Method Detail</h2>
+
+ <div class="entry-detail" id="add&#40;path:String,io:IO,method:CompressionMethod&#61;&lt;spanclass&#61;&quot;t&quot;&gt;CompressionMethod&lt;/span&gt;&lt;spanclass&#61;&quot;t&quot;&gt;::&lt;/span&gt;&lt;spanclass&#61;&quot;t&quot;&gt;DEFLATE&lt;/span&gt;,time:Time&#61;&lt;spanclass&#61;&quot;t&quot;&gt;Time&lt;/span&gt;.now,comment:String&#61;&lt;spanclass&#61;&quot;s&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&#41;:UInt32-instance-method">
+ <div class="signature">
+
+ def <strong>add</strong>(path : String, io : IO, method : <a href="../Zip/CompressionMethod.html">CompressionMethod</a> = <span class="t">CompressionMethod</span><span class="t">::</span><span class="t">DEFLATE</span>, time : Time = <span class="t">Time</span>.now, comment : String = <span class="s">&quot;&quot;</span>) : UInt32
+
+ <a class="method-permalink" href="#add%28path%3AString%2Cio%3AIO%2Cmethod%3ACompressionMethod%3D%3Cspanclass%3D%22t%22%3ECompressionMethod%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFLATE%3C%2Fspan%3E%2Ctime%3ATime%3D%3Cspanclass%3D%22t%22%3ETime%3C%2Fspan%3E.now%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%29%3AUInt32-instance-method">#</a>
+ </div>
+
+ <div class="doc"><p>Read data from <code>IO</code> <em>io</em>, write it to <em>path</em> in archive, then
+return the number of bytes written.</p>
+
+<p>Example:</p>
+
+<p># create IO from "/path/to/bar.txt"
+File.open("/path/to/bar.txt, "rb") do |io|
+# write to "foo.zip"
+Zip.write("foo.zip") do |zip|
+# add "bar.txt" with contents of given IO
+zip.add("bar.txt", io)
+end
+end</p></div>
+
+ <br/>
+ <div>
+
+ </div>
+ </div>
+
+ <div class="entry-detail" id="add&#40;path:String,data:String|Bytes,method:CompressionMethod&#61;&lt;spanclass&#61;&quot;t&quot;&gt;CompressionMethod&lt;/span&gt;&lt;spanclass&#61;&quot;t&quot;&gt;::&lt;/span&gt;&lt;spanclass&#61;&quot;t&quot;&gt;DEFLATE&lt;/span&gt;,time:Time&#61;&lt;spanclass&#61;&quot;t&quot;&gt;Time&lt;/span&gt;.now,comment:String&#61;&lt;spanclass&#61;&quot;s&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&#41;:UInt32-instance-method">
+ <div class="signature">
+
+ def <strong>add</strong>(path : String, data : String | Bytes, method : <a href="../Zip/CompressionMethod.html">CompressionMethod</a> = <span class="t">CompressionMethod</span><span class="t">::</span><span class="t">DEFLATE</span>, time : Time = <span class="t">Time</span>.now, comment : String = <span class="s">&quot;&quot;</span>) : UInt32
+
+ <a class="method-permalink" href="#add%28path%3AString%2Cdata%3AString%7CBytes%2Cmethod%3ACompressionMethod%3D%3Cspanclass%3D%22t%22%3ECompressionMethod%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFLATE%3C%2Fspan%3E%2Ctime%3ATime%3D%3Cspanclass%3D%22t%22%3ETime%3C%2Fspan%3E.now%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%29%3AUInt32-instance-method">#</a>
+ </div>
+
+ <div class="doc"><p>Write <em>data</em> to <em>path</em> in archive and return number of bytes
+written.</p>
+
+<p>Example:</p>
+
+<p># write to "foo.zip"
+Zip.write("foo.zip") do |zip|
+# add "bar.txt" with contents "hello!"
+zip.add("bar.txt", "hello!")
+end</p></div>
+
+ <br/>
+ <div>
+
+ </div>
+ </div>
+
+ <div class="entry-detail" id="add_file&#40;path:String,file_path:String,method:CompressionMethod&#61;&lt;spanclass&#61;&quot;t&quot;&gt;CompressionMethod&lt;/span&gt;&lt;spanclass&#61;&quot;t&quot;&gt;::&lt;/span&gt;&lt;spanclass&#61;&quot;t&quot;&gt;DEFLATE&lt;/span&gt;,time:Time&#61;&lt;spanclass&#61;&quot;t&quot;&gt;Time&lt;/span&gt;.now,comment:String&#61;&lt;spanclass&#61;&quot;s&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;&#41;:UInt32-instance-method">
+ <div class="signature">
+
+ def <strong>add_file</strong>(path : String, file_path : String, method : <a href="../Zip/CompressionMethod.html">CompressionMethod</a> = <span class="t">CompressionMethod</span><span class="t">::</span><span class="t">DEFLATE</span>, time : Time = <span class="t">Time</span>.now, comment : String = <span class="s">&quot;&quot;</span>) : UInt32
+
+ <a class="method-permalink" href="#add_file%28path%3AString%2Cfile_path%3AString%2Cmethod%3ACompressionMethod%3D%3Cspanclass%3D%22t%22%3ECompressionMethod%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3E%3A%3A%3C%2Fspan%3E%3Cspanclass%3D%22t%22%3EDEFLATE%3C%2Fspan%3E%2Ctime%3ATime%3D%3Cspanclass%3D%22t%22%3ETime%3C%2Fspan%3E.now%2Ccomment%3AString%3D%3Cspanclass%3D%22s%22%3E%26quot%3B%26quot%3B%3C%2Fspan%3E%29%3AUInt32-instance-method">#</a>
+ </div>
+
+ <div class="doc"><p>Add local file <em>file_path</em> to archive as <em>path</em> and return number
+of bytes written.</p>
+
+<p>Example:</p>
+
+<p># write to "foo.zip"
+Zip.write("foo.zip") do |zip|
+# add local file "/path/to/bar.txt" as "bar.txt"
+zip.add_file("bar.txt", "/path/to/bar.txt")
+end</p></div>
+
+ <br/>
+ <div>
+
+ </div>
+ </div>
+
+ <div class="entry-detail" id="bytes_written:UInt32-instance-method">
+ <div class="signature">
+
+ def <strong>bytes_written</strong> : UInt32
+
+ <a class="method-permalink" href="#bytes_written%3AUInt32-instance-method">#</a>
+ </div>
+
+ <div class="doc"><p>Return the total number of bytes written so far.</p>
+
+<p>Example:</p>
+
+<p>Zip.write("foo.zip") do |zip|
+# add "bar.txt"
+zip.add_file("bar.txt", "/path/to/bar.txt")</p>
+
+<pre><code><span class="c"># print number of bytes written so far</span>
+puts <span class="s">&quot;bytes written so far: </span><span class="i">#{</span></span>zip.bytes_written<span class="s"><span class="i">}</span>&quot;</span></code></pre>
+
+<p>end</p></div>
+
+ <br/>
+ <div>
+
+ </div>
+ </div>
+
+ <div class="entry-detail" id="close-instance-method">
+ <div class="signature">
+
+ def <strong>close</strong>
+
+ <a class="method-permalink" href="#close-instance-method">#</a>
+ </div>
+
+ <div class="doc"><p>Close this writer and return the total number of bytes written.</p></div>
+
+ <br/>
+ <div>
+
+ </div>
+ </div>
+
+ <div class="entry-detail" id="closed?:Bool-instance-method">
+ <div class="signature">
+
+ def <strong>closed?</strong> : Bool
+
+ <a class="method-permalink" href="#closed%3F%3ABool-instance-method">#</a>
+ </div>
+
+ <div class="doc"><p>Is this <code><a href="../Zip/Writer.html">Writer</a></code> closed?</p></div>
+
+ <br/>
+ <div>
+
+ </div>
+ </div>
+
+
+
+
+
+</div>
+
+</body>
+</html>