604: def each_entry
605: loop do
606: return if @io.eof?
607:
608: header = Archive::Tar::PosixHeader.new_from_stream(@io)
609: return if header.empty?
610:
611: entry = EntryStream.new(header, @io)
612: size = entry.size
613:
614: yield entry
615:
616: skip = (512 - (size % 512)) % 512
617:
618: if @io.respond_to?(:seek)
619:
620: @io.seek(size - entry.bytes_read, IO::SEEK_CUR)
621: else
622: pending = size - entry.bytes_read
623: while pending > 0
624: bread = @io.read([pending, 4096].min).size
625: raise UnexpectedEOF if @io.eof?
626: pending -= bread
627: end
628: end
629: @io.read(skip)
630:
631: entry.close
632: end
633: end