Sha256: 20faed1c580df39da47e70b53b7ffe5fbb5177186419155dc110e7d14beff75e

Contents?: true

Size: 823 Bytes

Versions: 22

Compression:

Stored size: 823 Bytes

Contents

module PSWindows::File
  include Beaker::CommandFactory

  def tmpfile(name = '')
    result = exec(powershell('[System.IO.Path]::GetTempFileName()'))
    result.stdout.chomp()
  end

  def tmpdir(name = '')
    tmp_path = exec(powershell('[System.IO.Path]::GetTempPath()')).stdout.chomp()

    if name == ''
      name = exec(powershell('[System.IO.Path]::GetRandomFileName()')).stdout.chomp()
    end
    exec(powershell("New-Item -Path '#{tmp_path}' -Force -Name '#{name}' -ItemType 'directory'"))
    File.join(tmp_path, name)
  end

  def path_split(paths)
    paths.split(';')
  end

  def cat(path)
    exec(powershell("type #{path}")).stdout
  end

  def file_exist?(path)
    result = exec(Beaker::Command.new("if exist #{path} echo true"), accept_all_exit_codes: true)
    result.stdout.strip == 'true'
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
beaker-4.25.0 lib/beaker/host/pswindows/file.rb
beaker-4.24.0 lib/beaker/host/pswindows/file.rb