Sha256: 5eb291e2152ff5f9c33f1d4c559bcd75efd20848e24343fa6acb213a9869e984

Contents?: true

Size: 893 Bytes

Versions: 99

Compression:

Stored size: 893 Bytes

Contents

class Dir
  # @api private
  def self.mktmpdir(prefix_suffix=nil, tmpdir=nil)
    case prefix_suffix
    when nil
      prefix = "d"
      suffix = ""
    when String
      prefix = prefix_suffix
      suffix = ""
    when Array
      prefix = prefix_suffix[0]
      suffix = prefix_suffix[1]
    else
      raise ArgumentError, "unexpected prefix_suffix: #{prefix_suffix.inspect}"
    end
    tmpdir ||= Dir.tmpdir
    t = Time.now.strftime("%Y%m%d")
    n = nil
    begin
      path = "#{tmpdir}/#{prefix}#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
      path << "-#{n}" if n
      path << suffix
      Dir.mkdir(path, 0700)
    rescue Errno::EEXIST
      n ||= 0
      n += 1
      retry
    end

    if block_given?
      begin
        yield path
      ensure
        FileUtils.remove_entry_secure path
      end
    else
      path
    end
  end unless respond_to? :mktmpdir # > 1.8.7
end

Version data entries

99 entries across 99 versions & 5 rubygems

Version Path
selenium-webdriver-2.45.0 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.45.0.dev3 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.45.0.dev2 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.45.0.dev lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.44.0 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.44.0.dev lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.43.0 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.42.0 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.41.0 lib/selenium/webdriver/common/core_ext/dir.rb
browserstack-webdriver-2.40.1 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.40.0 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.40.0.rc2 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.40.0.rc1 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.39.0 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.38.0 lib/selenium/webdriver/common/core_ext/dir.rb
browserstack-webdriver-0.0.22 lib/selenium/webdriver/common/core_ext/dir.rb
browserstack-webdriver-0.0.1 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.37.0 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.35.1 lib/selenium/webdriver/common/core_ext/dir.rb
selenium-webdriver-2.35.0 lib/selenium/webdriver/common/core_ext/dir.rb