class Crystar::Reader

Overview

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

Defined in:

tar/reader.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(io : IO, sync_close : Bool = false) #

Creates a new reader from the given io.


[View source]
def self.new(filename : String) #

Creates a new reader from the given filename.


[View source]

Class Method Detail

def self.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.


[View source]
def self.open(filename : String, &) #

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


[View source]

Instance Method Detail

def close #

Closes Crystar reader


[View source]
def closed? : Bool #

Returns true if this reader is closed.


[View source]
def each_entry(&) #

Yields each entry in the tar to the given block.


[View source]
def next_entry : Header | Nil #

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


[View source]
def sync_close=(sync_close : Bool) #

Whether to close the enclosed IO when closing this reader.


[View source]
def sync_close? : Bool #

Whether to close the enclosed IO when closing this reader.


[View source]