# File lib/archive/zip.rb, line 62
    def self.archive(archive, paths, options = {})
      if archive.kind_of?(String) && File.exist?(archive) then
        # Update the archive "in place".
        tmp_archive_path = nil
        File.open(archive) do |archive_in|
          Tempfile.open(*File.split(archive_in.path).reverse) do |archive_out|
            # Save off the path so that the temporary file can be renamed to the
            # archive file later.
            tmp_archive_path = archive_out.path
            # Ensure the file is in binary mode for Windows.
            archive_out.binmode
            # Update the archive.
            open(archive_in, :r) do |z_in|
              open(archive_out, :w) do |z_out|
                z_in.each  { |entry| z_out << entry }
                z_out.archive(paths, options)
              end
            end
          end
        end
        # Set more reasonable permissions than those set by Tempfile.
        File.chmod(0666 & ~File.umask, tmp_archive_path)
        # Replace the input archive with the output archive.
        File.rename(tmp_archive_path, archive)
      else
        open(archive, :w) { |z| z.archive(paths, options) }
      end
    end