EntryStreams are pseudo-streams on top of the main data stream.
# File lib/archive/tar/minitar/reader.rb, line 26 def initialize(header, io) @io = io @name = header.name @mode = header.mode @uid = header.uid @gid = header.gid @size = header.size @mtime = header.mtime @checksum = header.checksum @typeflag = header.typeflag @linkname = header.linkname @magic = header.magic @version = header.version @uname = header.uname @gname = header.gname @devmajor = header.devmajor @devminor = header.devminor @prefix = header.prefix @read = 0 @orig_pos = if Archive::Tar::Minitar.seekable?(@io) @io.pos else 0 end end
# File lib/archive/tar/minitar/reader.rb, line 105 def bytes_read @read end
Closes the entry.
# File lib/archive/tar/minitar/reader.rb, line 124 def close invalidate end
Returns false if the entry stream is valid.
# File lib/archive/tar/minitar/reader.rb, line 119 def closed? false end
Returns true
if the entry represents a directory.
# File lib/archive/tar/minitar/reader.rb, line 74 def directory? @typeflag == '5' end
Returns true
if the current read pointer is at the end of the
EntryStream data.
# File lib/archive/tar/minitar/reader.rb, line 87 def eof? @read >= @size end
Returns true
if the entry represents a plain file.
# File lib/archive/tar/minitar/reader.rb, line 80 def file? @typeflag == '0' || @typeflag == "\00"" end
Returns the full and proper name of the entry.
# File lib/archive/tar/minitar/reader.rb, line 110 def full_name if @prefix != '' File.join(@prefix, @name) else @name end end
Reads one byte from the entry. Returns nil
if there is no more
data to read.
# File lib/archive/tar/minitar/reader.rb, line 66 def getc return nil if @read >= @size ret = @io.getc @read += 1 if ret ret end
Returns the current read pointer in the EntryStream.
# File lib/archive/tar/minitar/reader.rb, line 92 def pos @read end
Reads len
bytes (or all remaining data) from the entry.
Returns nil
if there is no more data to read.
# File lib/archive/tar/minitar/reader.rb, line 55 def read(len = nil) return nil if @read >= @size len ||= @size - @read max_read = [len, @size - @read].min ret = @io.read(max_read) @read += ret.size ret end
Sets the current read pointer to the beginning of the EntryStream.
# File lib/archive/tar/minitar/reader.rb, line 97 def rewind unless Archive::Tar::Minitar.seekable?(@io, :pos=) raise Archive::Tar::Minitar::NonSeekableStream end @io.pos = @orig_pos @read = 0 end