From d64ce278f01cafc1c3c23aec9bb2394412ad160b Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Thu, 11 Aug 2016 00:30:34 -0400 Subject: update documentation --- Zip.html | 32 +++- Zip/Archive.html | 110 ++++++++++-- Zip/CompressionMethod.html | 24 ++- Zip/DeflateCompressionHelper.html | 26 ++- Zip/Entry.html | 318 +++++++++++++++++++++++++++++------ Zip/Error.html | 24 ++- Zip/Extra.html | 24 ++- Zip/GeneralFlags.html | 24 ++- Zip/NoneCompressionHelper.html | 26 ++- Zip/Source.html | 24 ++- Zip/TimeHelper.html | 26 ++- Zip/Version.html | 54 +++++- Zip/Writer.html | 63 ++++++- Zip/WriterEntry.html | 319 ----------------------------------- Zip/Writers/DirEntry.html | 292 ++++++++++++++++++++++++++++++++ Zip/Writers/FileEntry.html | 315 ++++++++++++++++++++++++++++++++++ Zip/Writers/WriterEntry.html | 343 ++++++++++++++++++++++++++++++++++++++ index.html | 39 +++-- 18 files changed, 1657 insertions(+), 426 deletions(-) delete mode 100644 Zip/WriterEntry.html create mode 100644 Zip/Writers/DirEntry.html create mode 100644 Zip/Writers/FileEntry.html create mode 100644 Zip/Writers/WriterEntry.html diff --git a/Zip.html b/Zip.html index b28c867..ca16367 100644 --- a/Zip.html +++ b/Zip.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -124,7 +144,7 @@ mem_io = MemoryIO. # read from "foo.zip" Zip.read("foo.zip") do |zip| # read contents of "bar.txt" in "foo.zip" into mem_io - zip["bar.txt"].read(mem_io) + zip["bar.txt"].write(mem_io) end

    Writing to a zip file:

    @@ -260,7 +280,7 @@ io = MemoryIO.new< # extract "bar.txt" from zip archive in Slice some_slice and # save it to MemoryIO Zip.read(some_slice) do |zip| - zip["bar.txt"].read(io) + zip["bar.txt"].write(io) end
    @@ -286,7 +306,7 @@ io = MemoryIO.new< # extract "bar.txt" from "foo.zip" and save it to MemoryIO Zip.read("foo.zip") do |zip| - zip["bar.txt"].read(io) + zip["bar.txt"].write(io) end
    @@ -313,7 +333,7 @@ io = MemoryIO.new< # read "bar.txt" from "foo.zip" Zip.read(File.open("foo.zip", "rb")) do |zip| - zip["bar.txt"].read(io) + zip["bar.txt"].write(io) end
    diff --git a/Zip/Archive.html b/Zip/Archive.html index 332b0f1..cb75fac 100644 --- a/Zip/Archive.html +++ b/Zip/Archive.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -195,31 +215,43 @@
  • #comment : String +

    Get the Archive comment as a String.

    +
  • #each(*args, **options, &block) +

    Iterate over the entries in this Archive, or, if called without a block, return a lazy iterator.

    +
  • #each(*args, **options) +

    Iterate over the entries in this Archive, or, if called without a block, return a lazy iterator.

    +
  • #entries : Array(Zip::Entry) +

    Return an array of entries in this Archive.

    +
  • #size(*args, **options, &block) +

    Return the number of entries in this Archive.

    +
  • #size(*args, **options) +

    Return the number of entries in this Archive.

    +
  • @@ -298,9 +330,9 @@

    Example:

    -
    # get bar.txt and read it into memory io
    +
    # get bar.txt and write it into memory io
     io = MemoryIO.new
    -zip["bar.txt"].read(io)
    +zip["bar.txt"].write(io)

    @@ -320,9 +352,9 @@ zip["bar.txt"].read(io)

    Example:

    -
    # read third entry from archive into memory io
    +
    # write contents of third entry from archive into memory io
     io = MemoryIO.new
    -zip[2].read(io)
    +zip[2].write(io)

    @@ -342,10 +374,10 @@ zip[2].read(io)

    Example:

    -
    # read third entry from archive into memory io
    +
    # write contents of third entry from archive into memory io
     if e = zip[2]?
       io = MemoryIO.new
    -  e.read(io)
    +  e.write(io)
     end

    @@ -366,10 +398,10 @@ zip[2].read(io)

    Example:

    -
    # read bar.txt into memory io if it exists
    +
    # write contents of "bar.txt" into memory io if it exists
     if e = zip["bar.txt"]?
       io = MemoryIO.new
    -  e.read(io)
    +  e.write(io)
     end

    @@ -386,6 +418,15 @@ zip[2].read(io)
    # +

    Get the Archive comment as a String.

    + +

    Example:

    + +
    Zip.read("foo.zip") do |zip|
    +  # print archive comment
    +  puts "comment: #{zip.comment}"
    +end
    +
    @@ -400,6 +441,18 @@ zip[2].read(io)
    # +

    Iterate over the entries in this Archive, or, if called without +a block, return a lazy iterator.

    + +

    Example:

    + +
    Zip.read("foo.zip") do |zip|
    +  zip.each do |e|
    +    type = e.dir? ? "directory" : "file"
    +    puts "#{e.path} is a #{type}"
    +  end
    +end
    +
    @@ -414,6 +467,18 @@ zip[2].read(io)
    # +

    Iterate over the entries in this Archive, or, if called without +a block, return a lazy iterator.

    + +

    Example:

    + +
    Zip.read("foo.zip") do |zip|
    +  zip.each do |e|
    +    type = e.dir? ? "directory" : "file"
    +    puts "#{e.path} is a #{type}"
    +  end
    +end
    +
    @@ -428,6 +493,15 @@ zip[2].read(io)
    # +

    Return an array of entries in this Archive.

    + +

    Example:

    + +
    Zip.read("foo.zip") do |zip|
    +  # get an array of entries in this archive
    +  entries = zip.entries
    +end
    +
    @@ -442,6 +516,14 @@ zip[2].read(io)
    # +

    Return the number of entries in this Archive.

    + +

    Example:

    + +
    Zip.read("foo.zip") do |zip|
    +  puts "foo.zip has #{zip.size} entries"
    +end
    +
    @@ -456,6 +538,14 @@ zip[2].read(io)
    # +

    Return the number of entries in this Archive.

    + +

    Example:

    + +
    Zip.read("foo.zip") do |zip|
    +  puts "foo.zip has #{zip.size} entries"
    +end
    +
    diff --git a/Zip/CompressionMethod.html b/Zip/CompressionMethod.html index f18b338..83b022f 100644 --- a/Zip/CompressionMethod.html +++ b/Zip/CompressionMethod.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • diff --git a/Zip/DeflateCompressionHelper.html b/Zip/DeflateCompressionHelper.html index 0b42f24..6daf337 100644 --- a/Zip/DeflateCompressionHelper.html +++ b/Zip/DeflateCompressionHelper.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -129,7 +149,7 @@
  • Zip::Entry
  • -
  • Zip::WriterEntry
  • +
  • Zip::Writers::FileEntry
  • diff --git a/Zip/Entry.html b/Zip/Entry.html index 9e31614..02dd78d 100644 --- a/Zip/Entry.html +++ b/Zip/Entry.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -184,35 +204,56 @@ io = MemoryIO.new<
  • #comment : String +

    Get comment for this Entry as a String.

    +
  • #compressed_size : UInt32 +

    Get compressed size for this Entry as a UInt32.

    +
  • #crc : UInt32 +

    Get CRC-32 for this Entry as a UInt32.

    + +
  • + +
  • + #dir? : Bool + +

    Returns true if this entry a directory.

    +
  • - #external_attr : UInt32 + #external : UInt32 + +

    Get external attributes for this Entry as a UInt32.

  • #extras : Array(Zip::Extra) +

    Get Extra data for this Entry as an Array.

    +
  • #flags : UInt16 +

    Get GeneralFlags for this Entry.

    +
  • - #internal_attr : UInt16 + #internal : UInt16 + +

    Get internal attributes for this Entry as a UInt16.

  • @@ -226,49 +267,63 @@ io = MemoryIO.new<
  • #method : Zip::CompressionMethod +

    Get CompressionMethod for this Entry.

    +
  • #path : String +

    Get path for this Entry as a String.

    +
  • #pos : UInt32 +

    Get position for this Entry as a UInt32.

    +
  • - #read(dst_io : IO) : UInt32 + #size : UInt32 -

    Write contents of Entry into given IO.

    +

    Get uncompressed size for this Entry as a UInt32.

  • - #size : UInt32 + #time : Time -

    Return the uncompressed size of this entry in bytes.

    +

    Get Time for this Entry.

  • - #time : Time + #version : UInt16 + +

    Get Version used to generate this Entry.

  • - #uncompressed_size : UInt32 + #version_needed : UInt16 + +

    Get Version needed to generate this Entry.

  • - #version : UInt16 + #write(path : String) : UInt32 + +

    Write contents of Entry into given path path and return the number of bytes written.

  • - #version_needed : UInt16 + #write(dst_io : IO) : UInt32 + +

    Write contents of Entry into given IO.

  • @@ -352,6 +407,15 @@ io = MemoryIO.new< #
    +

    Get comment for this Entry as a String.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print comment for each entry
    +  zip.each do |e|
    +    puts "#{e.path} comment: #{e.comment}"
    +  end
    +end
    +
    @@ -366,6 +430,15 @@ io = MemoryIO.new< #
    +

    Get compressed size for this Entry as a UInt32.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print compressed size for each entry
    +  zip.each do |e|
    +    puts "#{e.path} compressed size: #{e.compressed_size}"
    +  end
    +end
    +
    @@ -380,20 +453,61 @@ io = MemoryIO.new< #
    +

    Get CRC-32 for this Entry as a UInt32.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print crc for each entry
    +  zip.each do |e|
    +    puts "#{e.path} CRC-32: #{e.crc}"
    +  end
    +end
    +
    -
    +
    - def external_attr : UInt32 + def dir? : Bool - # + #
    +

    Returns true if this entry a directory.

    + +

    Example:

    + +
    Zip.read("foo.zip") do |zip|
    +  type = zip["some-dir/"].dir? ? "directory" : "file"
    +  puts "#{path} is a #{type}"
    +end
    + +
    +
    + +
    +
    + +
    +
    + + def external : UInt32 + + # +
    + +

    Get external attributes for this Entry as a UInt32.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print external attributes for each entry
    +  zip.each do |e|
    +    puts "#{e.path} external attributes: #{e.external}"
    +  end
    +end
    +
    @@ -408,6 +522,15 @@ io = MemoryIO.new< #
    +

    Get Extra data for this Entry as an Array.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print number of extra data items for each entry
    +  zip.each do |e|
    +    puts "#{e.path} extras: #{e.extras.size}"
    +  end
    +end
    +
    @@ -422,20 +545,38 @@ io = MemoryIO.new< #
    +

    Get GeneralFlags for this Entry.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print flags for each entry
    +  zip.each do |e|
    +    puts "#{e.path} flags: #{e.flags}"
    +  end
    +end
    +
    -
    +
    - def internal_attr : UInt16 + def internal : UInt16 - # + #
    +

    Get internal attributes for this Entry as a UInt16.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print internal attributes for each entry
    +  zip.each do |e|
    +    puts "#{e.path} internal attributes: #{e.internal}"
    +  end
    +end
    +
    @@ -482,6 +623,15 @@ file's entry in the Central Directory, and this method returns the #
    +

    Get CompressionMethod for this Entry.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print compression method for each entry
    +  zip.each do |e|
    +    puts "#{e.path} compression method: #{e.method}"
    +  end
    +end
    +
    @@ -496,6 +646,15 @@ file's entry in the Central Directory, and this method returns the #
    +

    Get path for this Entry as a String.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print uncompressed size for each entry
    +  zip.each do |e|
    +    puts "#{e.path}"
    +  end
    +end
    +
    @@ -510,33 +669,35 @@ file's entry in the Central Directory, and this method returns the #
    +

    Get position for this Entry as a UInt32.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print position for each entry
    +  zip.each do |e|
    +    puts "#{e.path} position: #{e.pos}"
    +  end
    +end
    +
    -
    +
    - def read(dst_io : IO) : UInt32 + def size : UInt32 - # + #
    -

    Write contents of Entry into given IO.

    - -

    Raises an Error if the file contents could not be read or if the -compression method is unsupported.

    +

    Get uncompressed size for this Entry as a UInt32.

    -

    Example:

    - -
    # open "output-bar.txt" for writing
    -File.open("output-bar.txt", "wb") do |io|
    -  # open archive "./foo.zip"
    -  Zip.read("foo.zip") do |zip|
    -    # write contents of "bar.txt" to "output-bar.txt"
    -    zip["foo.txt"].read(io)
    +
    Zip.read("foo.zip") do |zip|
    +  # print uncompressed size for each entry
    +  zip.each do |e|
    +    puts "#{e.path} uncompressed size: #{e.size}"
       end
     end
    @@ -546,21 +707,21 @@ compression method is unsupported.

    -
    +
    - def size : UInt32 + def time : Time - # + #
    -

    Return the uncompressed size of this entry in bytes.

    - -

    Example:

    +

    Get Time for this Entry.

    Zip.read("foo.zip") do |zip|
    -  size = zip["bar.txt"].size
    -  puts "bar.txt is #{size} bytes."
    +  # print time for each entry
    +  zip.each do |e|
    +    puts "#{e.path} time: #{e.time}"
    +  end
     end

    @@ -569,56 +730,107 @@ compression method is unsupported.

    -
    +
    - def time : Time + def version : UInt16 - # + #
    +

    Get Version used to generate this Entry.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print version used for each entry
    +  zip.each do |e|
    +    puts "#{e.path} version used: #{e.version}"
    +  end
    +end
    +
    -
    +
    - def uncompressed_size : UInt32 + def version_needed : UInt16 - # + #
    +

    Get Version needed to generate this Entry.

    + +
    Zip.read("foo.zip") do |zip|
    +  # print version needed to extract each entry
    +  zip.each do |e|
    +    puts "#{e.path} version needed: #{e.version_needed}"
    +  end
    +end
    +
    -
    +
    - def version : UInt16 + def write(path : String) : UInt32 - # + #
    +

    Write contents of Entry into given path path and return the +number of bytes written.

    + +

    Raises an Error if the file contents could not be read or if the +compression method is unsupported.

    + +

    Example:

    + +
    # open "output-bar.txt" for writing
    +File.open("output-bar.txt", "wb") do |io|
    +  # open archive "./foo.zip"
    +  Zip.read("foo.zip") do |zip|
    +    # write contents of "bar.txt" to "output-bar.txt"
    +    zip["foo.txt"].write(io)
    +  end
    +end
    +
    -
    +
    - def version_needed : UInt16 + def write(dst_io : IO) : UInt32 - # + #
    +

    Write contents of Entry into given IO.

    + +

    Raises an Error if the file contents could not be read or if the +compression method is unsupported.

    + +

    Example:

    + +
    # open "output-bar.txt" for writing
    +File.open("output-bar.txt", "wb") do |io|
    +  # open archive "./foo.zip"
    +  Zip.read("foo.zip") do |zip|
    +    # write contents of "bar.txt" to "output-bar.txt"
    +    zip["foo.txt"].write(io)
    +  end
    +end
    +
    diff --git a/Zip/Error.html b/Zip/Error.html index d2a611e..6aeba81 100644 --- a/Zip/Error.html +++ b/Zip/Error.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • diff --git a/Zip/Extra.html b/Zip/Extra.html index 3ea15f3..554e82b 100644 --- a/Zip/Extra.html +++ b/Zip/Extra.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • diff --git a/Zip/GeneralFlags.html b/Zip/GeneralFlags.html index 4831e42..8778ab7 100644 --- a/Zip/GeneralFlags.html +++ b/Zip/GeneralFlags.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • diff --git a/Zip/NoneCompressionHelper.html b/Zip/NoneCompressionHelper.html index f508f52..b8b8be6 100644 --- a/Zip/NoneCompressionHelper.html +++ b/Zip/NoneCompressionHelper.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -129,7 +149,7 @@
  • Zip::Entry
  • -
  • Zip::WriterEntry
  • +
  • Zip::Writers::FileEntry
  • diff --git a/Zip/Source.html b/Zip/Source.html index 6c94cbc..894aef1 100644 --- a/Zip/Source.html +++ b/Zip/Source.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • diff --git a/Zip/TimeHelper.html b/Zip/TimeHelper.html index ed3ffad..de19300 100644 --- a/Zip/TimeHelper.html +++ b/Zip/TimeHelper.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -129,7 +149,7 @@
  • Zip::Entry
  • -
  • Zip::WriterEntry
  • +
  • Zip::Writers::WriterEntry
  • diff --git a/Zip/Version.html b/Zip/Version.html index a555534..f8a04b4 100644 --- a/Zip/Version.html +++ b/Zip/Version.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -120,6 +140,12 @@ attributes.

    See section 4.4.3.2 of APPNOTE.TXT for version details.

    +

    Example:

    + +
    # create version and print it out
    +version = Zip::Version.new(5, 0)
    +puts "version = #{version}"
    + @@ -239,7 +265,13 @@ attributes.

    Create a version identifier from a major number, minor number, and -optional compatability number.

    +optional compatability number.

    + +

    Example:

    + +
    # create version and print it out
    +version = Zip::Version.new(5, 0)
    +puts "version = #{version}"

    @@ -256,7 +288,10 @@ optional compatability number.

    Create a version identifier from a major number, minor number, and -optional compatability number.

    +optional compatability number.

    + +

    You shouldn't need to call this constructor directly; it is used +by internal classes.


    @@ -278,7 +313,10 @@ optional compatability number.

    Write version as 16-bit, little-endian integer and return number -of bytes written.

    +of bytes written.

    + +

    You shouldn't need to call this method directly; it is used by +internal classes.


    @@ -294,7 +332,11 @@ of bytes written.

    #
    -

    Write version as string.

    +

    Write version as string.

    + +
    # create version and print it out
    +version = Zip::Version.new(5, 0)
    +puts "version = #{version}"

    diff --git a/Zip/Writer.html b/Zip/Writer.html index 894055d..0b4a935 100644 --- a/Zip/Writer.html +++ b/Zip/Writer.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -112,6 +132,13 @@ +

    Overview

    + +

    Zip file writer.

    + +

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

    + @@ -163,6 +190,13 @@ +
  • + #add_dir(path : String, time : Time = Time.now, comment : String = "") : UInt32 + +

    Add empty directory to archive as path and return number of bytes written.

    + +
  • +
  • #add_file(path : String, file_path : String, method : CompressionMethod = CompressionMethod::DEFLATE, time : Time = Time.now, comment : String = "") : UInt32 @@ -295,6 +329,31 @@ written.

  • +
    +
    + + def add_dir(path : String, time : Time = Time.now, comment : String = "") : UInt32 + + # +
    + +

    Add empty directory to archive as path and return number of +bytes written.

    + +

    Example:

    + +
    # write to "foo.zip"
    +Zip.write("foo.zip") do |zip|
    +  # add a directory named "example-dir"
    +  zip.add_dir("example-dir")
    +end
    + +
    +
    + +
    +
    +
    diff --git a/Zip/WriterEntry.html b/Zip/WriterEntry.html deleted file mode 100644 index 843b04b..0000000 --- a/Zip/WriterEntry.html +++ /dev/null @@ -1,319 +0,0 @@ - - - - - - - - Zip::WriterEntry - github.com/pablotron/zip-crystal - - - -
    - - - - - - -
    - -
    -

    - - class Zip::WriterEntry - -

    - - - - - - - -

    Overview

    - -

    Internal class used to store files for Writer instance.

    - -

    You should not need to instantiate this class directly; it is called -automatically by Writer#add and Writer#add_file.

    - - - - - -

    Included Modules

    - - - - - - - - - - - -

    Defined in:

    - - - - - -

    Constant Summary

    - -
    - -
    - GENERAL_FLAGS = GeneralFlags.flags(FOOTER, EFS) -
    - -
    -

    Default flags for local and central header.

    -
    - - -
    - - - -

    Class Method Summary

    - - - - -

    Instance Method Summary

    - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -

    Class Method Detail

    - -
    -
    - - def self.new(pos : UInt32, path : String, io : IO, method : CompressionMethod = CompressionMethod::DEFLATE, time : Time = Time.now, comment : String = "") - - # -
    - -

    Create a new WriterEntry instance.

    - -

    You should not need to call this method directly; it is called -automatically by Writer#add and Writer#add_file.

    - -
    -
    - -
    -
    - - - - -

    Instance Method Detail

    - -
    -
    - - def to_s(dst_io) : UInt32 - - # -
    - -

    Write local file entry to IO and return the number of bytes -written.

    - -

    You should not need to call this method directly; it is called -automatically by Writer#add and Writer#add_file.

    - -
    -
    - -
    -
    - -
    -
    - - def write_central(io : IO, version : Version = Version::DEFAULT) : UInt32 - - # -
    - -

    Write central directory data for this WriterEntry and return the -number of bytes written.

    - -

    You should not need to call this method directly; it is called -automatically by Writer#close.

    - -
    -
    - -
    -
    - - - - - -
    - - - diff --git a/Zip/Writers/DirEntry.html b/Zip/Writers/DirEntry.html new file mode 100644 index 0000000..a98b19c --- /dev/null +++ b/Zip/Writers/DirEntry.html @@ -0,0 +1,292 @@ + + + + + + + + Zip::Writers::DirEntry - github.com/pablotron/zip-crystal + + + +
    + + + + + + +
    + +
    +

    + + class Zip::Writers::DirEntry + +

    + + + + + + + +

    Overview

    + +

    Internal class used to store files for Writer instance.

    + +

    You should not need to instantiate this class directly; use +Writer#add_dir instead.

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

    Defined in:

    + + + + + +

    Constant Summary

    + +
    + +
    + FLAGS = GeneralFlags.flags(EFS) +
    + +
    +

    Default flags for local and central file header.

    +
    + + +
    + + + +

    Class Method Summary

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

    Class Method Detail

    + +
    +
    + + def self.new(pos : UInt32, path : String, time : Time = Time.now, comment : String = "") + + # +
    + +

    Create a new DirEntry instance.

    + +

    You should not need to call this method directly; use +Writer#add_dir instead.

    + +
    +
    + +
    +
    + + + + + + + +
    + + + diff --git a/Zip/Writers/FileEntry.html b/Zip/Writers/FileEntry.html new file mode 100644 index 0000000..b703720 --- /dev/null +++ b/Zip/Writers/FileEntry.html @@ -0,0 +1,315 @@ + + + + + + + + Zip::Writers::FileEntry - github.com/pablotron/zip-crystal + + + +
    + + + + + + +
    + +
    +

    + + class Zip::Writers::FileEntry + +

    + + + + + + + +

    Overview

    + +

    Internal class used to store files for Writer instance.

    + +

    You should not need to call this method directly; it is called +automatically by Writer#add and Writer#add_file.

    + + + + + +

    Included Modules

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

    Defined in:

    + + + + + +

    Constant Summary

    + +
    + +
    + FLAGS = GeneralFlags.flags(FOOTER, EFS) +
    + +
    +

    Flags for local and central file header.

    +
    + + +
    + + + +

    Class Method Summary

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

    Class Method Detail

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

    Create a new FileWriterEntry instance.

    + +

    You should not need to call this method directly; it is called +automatically by Writer#add and Writer#add_file.

    + +
    +
    + +
    +
    + + + + + + + +
    + + + diff --git a/Zip/Writers/WriterEntry.html b/Zip/Writers/WriterEntry.html new file mode 100644 index 0000000..9442e7a --- /dev/null +++ b/Zip/Writers/WriterEntry.html @@ -0,0 +1,343 @@ + + + + + + + + Zip::Writers::WriterEntry - github.com/pablotron/zip-crystal + + + +
    + + + + + + +
    + +
    +

    + + abstract class Zip::Writers::WriterEntry + +

    + + + + + + + +

    Overview

    + +

    Abstract base class for classes used to store files and directories +for Writer instance.

    + + + + + +

    Included Modules

    + + + + + + +

    Direct Known Subclasses

    + + + + + + + +

    Defined in:

    + + + + + + +

    Class Method Summary

    + + + + +

    Instance Method Summary

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

    Class Method Detail

    + +
    +
    + + def self.new(pos : UInt32, path : String, method : CompressionMethod = CompressionMethod::DEFLATE, time : Time = Time.now, comment : String = "", flags : GeneralFlags = GeneralFlags.flags, external : UInt32 = 0_u32) + + # +
    + +
    +
    + +
    +
    + + + + +

    Instance Method Detail

    + +
    +
    + + def to_s(dst_io) : UInt32 + + # +
    + +

    Write local file entry to IO and return the number of bytes +written.

    + +

    You should not need to call this method directly; it is called +automatically by Writer#add and Writer#add_file.

    + +
    +
    + +
    +
    + +
    +
    + abstract + def write_body(dst_io : IO) + + # +
    + +
    +
    + +
    +
    + +
    +
    + + def write_central(io : IO, version : Version = Version::DEFAULT) : UInt32 + + # +
    + +

    Write central directory data for this WriterEntry and return the +number of bytes written.

    + +

    You never need to call this method directly; it is called +automatically by Writer#close.

    + +
    +
    + +
    +
    + +
    +
    + abstract + def write_footer(io : IO, crc : UInt32, src_len : UInt32, dst_len : UInt32) : UInt32 + + # +
    + +
    +
    + +
    +
    + + + + + +
    + + + diff --git a/index.html b/index.html index 0314d29..264d607 100644 --- a/index.html +++ b/index.html @@ -85,8 +85,28 @@ -
  • - WriterEntry +
  • + Writers + + +
  • @@ -129,16 +149,13 @@ # create memory io mem_io = MemoryIO.new -# open "/some/other/path/image.png" for writing -File.open("/some/other/path/image.png", "wb") do |file_io| - # read from "foo.zip" - Zip.read("foo.zip") do |zip| - # extract "bar.txt" to mem_io - zip["bar.txt"].read(mem_io) +# read from "foo.zip" +Zip.read("foo.zip") do |zip| + # extract "bar.txt" to mem_io + zip["bar.txt"].write(mem_io) - # extract "image.png" to file_io - zip["image.png"].read(file_io) - end + # extract "image.png" to "output-image.png" + zip["image.png"].write("output-image.png") end

    See the API documentation -- cgit v1.2.3