class Zip::Entry

Overview

File entry in Archive.

Use Zip.read() to read a Zip archive, then #[] to fetch a specific archive entry.

Example:

# create MemoryIO io = MemoryIO.new

# open "foo.zip" Zip.read("foo.zip") do |zip| # get "bar.txt" entry from "foo.zip" e = zip["bar.txt"]

# read contents of "bar.txt" into io
e.read(io)

end

Included Modules

Defined in:

Class Method Summary

Instance Method Summary

Class Method Detail

def self.new(io : Source) #

Instantiate a new Entry object from the given IO.

You should not need to call this method directly (use Zip::Archive#[] instead).


Instance Method Detail

def comment : String #

def compressed_size : UInt32 #

def crc : UInt32 #

def external_attr : UInt32 #

def extras : Array(Zip::Extra) #

def flags : UInt16 #

def internal_attr : UInt16 #

def local_extras : Array(Extra) #

Returns an array of Extra attributes for this Entry.

Zip archives can (and do) have separate Extra attributes associated with the file entry itself, and the file's entry in the Central Directory.

The #extras method returns the Extra attributes from the file's entry in the Central Directory, and this method returns the Extra data from the file entry itself.

Example:

# open "./foo.zip" Zip.read("./foo.zip") do |zip| # get array of local extra attributes from "bar.txt" extras = zip["bar.txt"].local_extras end


def method : Zip::CompressionMethod #

def path : String #

def pos : UInt32 #

def read(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"].read(io) end end


def size : UInt32 #

Return the uncompressed size of this entry in bytes.

Example:

Zip.read("foo.zip") do |zip| size = zip["bar.txt"].size puts "bar.txt is #{size} bytes." end


def time : Time #

def uncompressed_size : UInt32 #

def version : UInt16 #

def version_needed : UInt16 #