extract_entry (Gem::Package::TarInput)

    # File lib/rubygems/package/tar_input.rb, line 135
      def extract_entry(destdir, entry, expected_md5sum = nil)
        if entry.directory? then
          dest = File.join destdir, entry.full_name

          if File.directory? dest then
            @fileops.chmod entry.header.mode, dest, :verbose => false
          else
            @fileops.mkdir_p dest, :mode => entry.header.mode, :verbose => false
          end

          fsync_dir dest
          fsync_dir File.join(dest, "..")

          return
        end

        # it's a file
        md5 = Digest::MD5.new if expected_md5sum
        destdir = File.join destdir, File.dirname(entry.full_name)
        @fileops.mkdir_p destdir, :mode => 0755, :verbose => false
        destfile = File.join destdir, File.basename(entry.full_name)
        @fileops.chmod 0600, destfile, :verbose => false rescue nil # Errno::ENOENT

        open destfile, "wb", entry.header.mode do |os|
          loop do
            data = entry.read 4096
            break unless data
            # HACK shouldn't we check the MD5 before writing to disk?
            md5 << data if expected_md5sum
            os.write(data)
          end

          os.fsync
        end

        @fileops.chmod entry.header.mode, destfile, :verbose => false
        fsync_dir File.dirname(destfile)
        fsync_dir File.join(File.dirname(destfile), "..")

        if expected_md5sum && expected_md5sum != md5.hexdigest then
          raise Gem::Package::BadCheckSum
        end
      end