From 25199ab4c29057d7c0a73812fc8f2ac3605c1d86 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Wed, 10 Aug 2016 21:04:41 -0400 Subject: add documentation --- Zip/Writer.html | 389 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 389 insertions(+) create mode 100644 Zip/Writer.html (limited to 'Zip/Writer.html') 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 @@ + + + + + + + + Zip::Writer - github.com/pablotron/zip-crystal + + + +
+ + + + + + +
+ +
+

+ + class Zip::Writer + +

+ + + + + + + + + + + + + + + + + + + + +

Defined in:

+ + + + + + +

Class Method Summary

+ + + + +

Instance Method Summary

+ + + + + + +
+ + + + + + + + + + + + + + + +
+ + +

Class Method Detail

+ +
+
+ + def self.new(io : IO, pos : UInt32 = 0, comment : String = "", version : Version = Version::DEFAULT) + + # +
+ +

Create a new Writer object.

+ +

You shouldn't need to instantiate this class directly; use +Zip.write() instead.

+ +
+
+ +
+
+ + + + +

Instance Method Detail

+ +
+
+ + def add(path : String, io : IO, method : CompressionMethod = CompressionMethod::DEFLATE, time : Time = Time.now, comment : String = "") : UInt32 + + # +
+ +

Read data from IO io, write it to path in archive, then +return the number of bytes written.

+ +

Example:

+ +

# 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

+ +
+
+ +
+
+ +
+
+ + def add(path : String, data : String | Bytes, method : CompressionMethod = CompressionMethod::DEFLATE, time : Time = Time.now, comment : String = "") : UInt32 + + # +
+ +

Write data to path in archive and return number of bytes +written.

+ +

Example:

+ +

# write to "foo.zip" +Zip.write("foo.zip") do |zip| +# add "bar.txt" with contents "hello!" +zip.add("bar.txt", "hello!") +end

+ +
+
+ +
+
+ +
+
+ + def add_file(path : String, file_path : String, method : CompressionMethod = CompressionMethod::DEFLATE, time : Time = Time.now, comment : String = "") : UInt32 + + # +
+ +

Add local file file_path to archive as path and return number +of bytes written.

+ +

Example:

+ +

# 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

+ +
+
+ +
+
+ +
+
+ + def bytes_written : UInt32 + + # +
+ +

Return the total number of bytes written so far.

+ +

Example:

+ +

Zip.write("foo.zip") do |zip| +# add "bar.txt" +zip.add_file("bar.txt", "/path/to/bar.txt")

+ +
# print number of bytes written so far
+puts "bytes written so far: #{zip.bytes_written}"
+ +

end

+ +
+
+ +
+
+ +
+
+ + def close + + # +
+ +

Close this writer and return the total number of bytes written.

+ +
+
+ +
+
+ +
+
+ + def closed? : Bool + + # +
+ +

Is this Writer closed?

+ +
+
+ +
+
+ + + + + +
+ + + -- cgit v1.2.3