Sha256: ede938b8a9aa4f76c208fb6c866207ee422613da88a98371b223602bd3eaeda0

Contents?: true

Size: 824 Bytes

Versions: 8

Compression:

Stored size: 824 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

8 entries across 8 versions & 1 rubygems

Version Path
beaker-4.42.0 lib/beaker/host/pswindows/file.rb
beaker-4.41.2 lib/beaker/host/pswindows/file.rb
beaker-4.41.1 lib/beaker/host/pswindows/file.rb
beaker-4.41.0 lib/beaker/host/pswindows/file.rb
beaker-4.40.2 lib/beaker/host/pswindows/file.rb
beaker-4.40.1 lib/beaker/host/pswindows/file.rb
beaker-4.40.0 lib/beaker/host/pswindows/file.rb
beaker-4.39.0 lib/beaker/host/pswindows/file.rb