class Archive::Tar::Minitar::Reader::EntryStream

EntryStreams are pseudo-streams on top of the main data stream.

Public Class Methods

new(header, anIO) click to toggle source
    # File lib/archive/tar/minitar.rb
470 def initialize(header, anIO)
471   @io       = anIO
472   @name     = header.name
473   @mode     = header.mode
474   @uid      = header.uid
475   @gid      = header.gid
476   @size     = header.size
477   @mtime    = header.mtime
478   @checksum = header.checksum
479   @typeflag = header.typeflag
480   @linkname = header.linkname
481   @magic    = header.magic
482   @version  = header.version
483   @uname    = header.uname
484   @gname    = header.gname
485   @devmajor = header.devmajor
486   @devminor = header.devminor
487   @prefix   = header.prefix
488   @read     = 0
489   @orig_pos = @io.pos
490 end

Public Instance Methods

bytes_read() click to toggle source
    # File lib/archive/tar/minitar.rb
542 def bytes_read
543   @read
544 end
close() click to toggle source

Closes the entry.

    # File lib/archive/tar/minitar.rb
556 def close
557   invalidate
558 end
directory()
Alias for: directory?
directory?() click to toggle source

Returns true if the entry represents a directory.

    # File lib/archive/tar/minitar.rb
513 def directory?
514   @typeflag == "5"
515 end
Also aliased as: directory
eof?() click to toggle source

Returns true if the current read pointer is at the end of the EntryStream data.

    # File lib/archive/tar/minitar.rb
526 def eof?
527   @read >= @size
528 end
file()
Alias for: file?
file?() click to toggle source

Returns true if the entry represents a plain file.

    # File lib/archive/tar/minitar.rb
519 def file?
520   @typeflag == "0" or @typeflag == "\0"
521 end
Also aliased as: file
full_name() click to toggle source

Returns the full and proper name of the entry.

    # File lib/archive/tar/minitar.rb
547 def full_name
548   if @prefix != ""
549     File.join(@prefix, @name)
550   else
551     @name
552   end
553 end
getc() click to toggle source

Reads one byte from the entry. Returns nil if there is no more data to read.

    # File lib/archive/tar/minitar.rb
505 def getc
506   return nil if @read >= @size
507   ret = @io.getc
508   @read += 1 if ret
509   ret
510 end
pos() click to toggle source

Returns the current read pointer in the EntryStream.

    # File lib/archive/tar/minitar.rb
531 def pos
532   @read
533 end
read(len = nil) click to toggle source

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.rb
494 def read(len = nil)
495   return nil if @read >= @size
496   len ||= @size - @read
497   max_read = [len, @size - @read].min
498   ret = @io.read(max_read)
499   @read += ret.size
500   ret
501 end
rewind() click to toggle source

Sets the current read pointer to the beginning of the EntryStream.

    # File lib/archive/tar/minitar.rb
536 def rewind
537   raise NonSeekableStream unless @io.respond_to?(:pos=)
538   @io.pos = @orig_pos
539   @read = 0
540 end

Private Instance Methods

invalidate() click to toggle source
    # File lib/archive/tar/minitar.rb
561 def invalidate
562   extend InvalidEntryStream
563 end