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