Module: Windows::File

Includes:
Beaker::CommandFactory
Included in:
Host
Defined in:
lib/beaker/host/windows/file.rb

Instance Attribute Summary

Attributes included from Beaker::CommandFactory

#assertions

Instance Method Summary collapse

Methods included from Beaker::CommandFactory

#execute, #fail_test

Instance Method Details

#file_exist?(path) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/beaker/host/windows/file.rb', line 41

def file_exist?(path)
  result = exec(Beaker::Command.new("test -e '#{path}'"), :acceptable_exit_codes => [0, 1])
  result.exit_code == 0
end

#path_split(paths) ⇒ Object



37
38
39
# File 'lib/beaker/host/windows/file.rb', line 37

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

#scp_path(path) ⇒ String

Note:

This will fail with an SSH server that is not OpenSSL or BitVise.

Updates a file path for use with SCP, depending on the SSH Server

Parameters:

  • path (String)

    Path to be changed

Returns:

  • (String)

    Path updated for use by SCP



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/beaker/host/windows/file.rb', line 25

def scp_path(path)
  case determine_ssh_server
  when :bitvise
    # swap out separators
    network_path = path.gsub('\\', scp_separator)
  when :openssh
    path
  else
    raise ArgumentError("windows/file.rb:scp_path: ssh server not recognized: '#{determine_ssh_server}'")
  end
end

#system_temp_pathObject



12
13
14
15
16
# File 'lib/beaker/host/windows/file.rb', line 12

def system_temp_path
  # under CYGWIN %TEMP% may not be set
  tmp_path = execute('ECHO %SYSTEMROOT%', :cmdexe => true)
  tmp_path.gsub(/\n/, '') + '\\TEMP'
end

#tmpdir(name) ⇒ Object



8
9
10
# File 'lib/beaker/host/windows/file.rb', line 8

def tmpdir(name)
  execute("cygpath -m $(mktemp -td #{name}.XXXXXX)")
end

#tmpfile(name) ⇒ Object



4
5
6
# File 'lib/beaker/host/windows/file.rb', line 4

def tmpfile(name)
  execute("cygpath -m $(mktemp -t #{name}.XXXXXX)")
end