<commit_before>require 'zip/zip'
require 'tempfile'
require 'find'

module Selenium
  module WebDriver
    module Zipper

      EXTENSIONS = %w[.zip .xpi]

      def self.unzip(path)
        destination = Dir.mktmpdir("unzip")
        FileReaper << destination

        Zip::ZipFile.open(path) do |zip|
          zip.each do |entry|
            to      = File.join(destination, entry.name)
            dirname = File.dirname(to)

            FileUtils.mkdir_p dirname unless File.exist? dirname
            zip.extract(entry, to)
          end
        end

        destination
      end

      def self.zip(path)
        tmp_zip = Tempfile.new("webdriver-zip")

        begin
          zos = Zip::ZipOutputStream.new(tmp_zip.path)

          ::Find.find(path) do |file|
            next if File.directory?(file)
            entry = file.sub("#{path}/", '')

            zos.put_next_entry(entry)
            zos << File.read(file)
          end
<commit_msg>JariBakken: Make sure we properly zip binary files on Windows.<commit_after>require 'zip/zip'
require 'tempfile'
require 'find'

module Selenium
  module WebDriver
    module Zipper

      EXTENSIONS = %w[.zip .xpi]

      def self.unzip(path)
        destination = Dir.mktmpdir("unzip")
        FileReaper << destination

        Zip::ZipFile.open(path) do |zip|
          zip.each do |entry|
            to      = File.join(destination, entry.name)
            dirname = File.dirname(to)

            FileUtils.mkdir_p dirname unless File.exist? dirname
            zip.extract(entry, to)
          end
        end

        destination
      end

      def self.zip(path)
        tmp_zip = Tempfile.new("webdriver-zip")

        begin
          zos = Zip::ZipOutputStream.new(tmp_zip.path)

          ::Find.find(path) do |file|
            next if File.directory?(file)
            entry = file.sub("#{path}/", '')

            zos.put_next_entry(entry)
            zos << File.read(file, "rb")
          end

{'fraction_non_alphanumeric': 0.10716099542915185, 'fraction_numerical': 0.0, 'mean_word_length': 1.822349570200573, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4927939', 'n_tokens_mistral': 622, 'n_tokens_neox': 581, 'n_words': 134}