Sha256: 6ab34422a59b9994cc433c5f12147247907057a721fdc12d7e3713f3a632b90c

Contents?: true

Size: 876 Bytes

Versions: 18

Compression:

Stored size: 876 Bytes

Contents

class Dir
  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

18 entries across 18 versions & 2 rubygems

Version Path
rainux-selenium-webdriver-0.0.17 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.17 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.16 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.15 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.14 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.13 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.12 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.11 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.10 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.9 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.8 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.7 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.6 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.5 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.4 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.3 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.2 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb
selenium-webdriver-0.0.1 common/src/rb/lib/selenium/webdriver/core_ext/dir.rb