class

Crystar::Reader

Inherits Reference < Object

Reads tar file entries sequentially from an IO.

Example

require "tar"

File.open("./file.tar") do |file|
  Crystar::Reader.open(file) do |tar|
    tar.each_entry do |entry|
      p entry.name
      p entry.file?
      p entry.dir?
      p entry.io.gets_to_end
    end
  end
end

Constructors

new(io : IO, sync_close : Bool = false)

Creates a new reader from the given io.

Source
new(filename : String)

Creates a new reader from the given filename.

Source

Class methods

open(io : IO, sync_close = false, &)

Creates a new reader from the given io, yields it to the given block, and closes it at the end.

Source
open(filename : String, &)

Creates a new reader from the given filename, yields it to the given block, and closes it at the end.

Source

Instance methods

close

Closes Crystar reader

Source
closed?

Returns true if this reader is closed.

Source
each_entry

Yields each entry in the tar to the given block.

Source
next_entry

next_entry advances to the next entry in the tar archive. The Header#size determines how many bytes can be read for the next file. Any remaining data in the current file is automatically discarded.

EOF is returned at the end of the input. ameba:disable Metrics/CyclomaticComplexity

Source
sync_close=(sync_close : Bool)

Whether to close the enclosed IO when closing this reader.

Source
sync_close?

Whether to close the enclosed IO when closing this reader.

Source

Nested types