class Crystar::Reader
- Crystar::Reader
- Reference
- Object
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.crConstructors
-
.new(io : IO, sync_close = false)
Creates a new reader from the given io.
-
.new(filename : String)
Creates a new reader from the given filename.
Class Method Summary
-
.open(io : IO, sync_close = false, &block)
Creates a new reader from the given io, yields it to the given block, and closes it at the end.
-
.open(filename : String, &block)
Creates a new reader from the given filename, yields it to the given block, and closes it at the end.
Instance Method Summary
-
#close
Closes Crystar reader
-
#closed? : Bool
Returns
true
if this reader is closed. -
#each_entry(&block)
Yields each entry in the zip to the given block.
-
#next_entry : Header?
next_entry advances to the next entry in the tar archive.
-
#sync_close=(sync_close)
Whether to close the enclosed
IO
when closing this reader. -
#sync_close? : Bool
Whether to close the enclosed
IO
when closing this reader.
Constructor Detail
Class Method Detail
Creates a new reader from the given io, yields it to the given block, and closes it at the end.
Creates a new reader from the given filename, yields it to the given block, and closes it at the end.
Instance Method Detail
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.