Parent

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, line 464
464:       def initialize(header, anIO)
465:         @io       = anIO
466:         @name     = header.name
467:         @mode     = header.mode
468:         @uid      = header.uid
469:         @gid      = header.gid
470:         @size     = header.size
471:         @mtime    = header.mtime
472:         @checksum = header.checksum
473:         @typeflag = header.typeflag
474:         @linkname = header.linkname
475:         @magic    = header.magic
476:         @version  = header.version
477:         @uname    = header.uname
478:         @gname    = header.gname
479:         @devmajor = header.devmajor
480:         @devminor = header.devminor
481:         @prefix   = header.prefix
482:         @read     = 0
483:         @orig_pos = @io.pos
484:       end

Public Instance Methods

bytes_read() click to toggle source
     # File lib/archive/tar/minitar.rb, line 536
536:       def bytes_read
537:         @read
538:       end
close() click to toggle source

Closes the entry.

     # File lib/archive/tar/minitar.rb, line 550
550:       def close
551:         invalidate
552:       end
directory() click to toggle source
Alias for: directory?
directory?() click to toggle source

Returns true if the entry represents a directory.

     # File lib/archive/tar/minitar.rb, line 507
507:       def directory?
508:         @typeflag == "5"
509:       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, line 520
520:       def eof?
521:         @read >= @size
522:       end
file() click to toggle source
Alias for: file?
file?() click to toggle source

Returns true if the entry represents a plain file.

     # File lib/archive/tar/minitar.rb, line 513
513:       def file?
514:         @typeflag == "0"
515:       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, line 541
541:       def full_name
542:         if @prefix != ""
543:           File.join(@prefix, @name)
544:         else
545:           @name
546:         end
547:       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, line 499
499:       def getc
500:         return nil if @read >= @size
501:         ret = @io.getc
502:         @read += 1 if ret
503:         ret
504:       end
pos() click to toggle source

Returns the current read pointer in the EntryStream.

     # File lib/archive/tar/minitar.rb, line 525
525:       def pos
526:         @read
527:       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, line 488
488:       def read(len = nil)
489:         return nil if @read >= @size
490:         len ||= @size - @read
491:         max_read = [len, @size - @read].min
492:         ret = @io.read(max_read)
493:         @read += ret.size
494:         ret
495:       end
rewind() click to toggle source

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

     # File lib/archive/tar/minitar.rb, line 530
530:       def rewind
531:         raise NonSeekableStream unless @io.respond_to?(:pos=)
532:         @io.pos = @orig_pos
533:         @read = 0
534:       end

Private Instance Methods

invalidate() click to toggle source
     # File lib/archive/tar/minitar.rb, line 555
555:       def invalidate
556:         extend InvalidEntryStream
557:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.