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

#chgrp(group, path, recursive = false) ⇒ Object

Note:

Cygwin’s ‘chgrp` implementation does not support windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style. This method simply wraps the normal Host#chgrp call with a call to cygpath to sanitize input.



33
34
35
36
# File 'lib/beaker/host/windows/file.rb', line 33

def chgrp(group, path, recursive=false)
  cygpath = execute("cygpath -u #{path}")
  super(group, cygpath, recursive)
end

#chmod(mod, path, recursive = false) ⇒ Object

Not needed on windows



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

def chmod(mod, path, recursive=false); end

#chown(user, path, recursive = false) ⇒ Object

Note:

Cygwin’s ‘chown` implementation does not support windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style. This method simply wraps the normal Host#chown call with a call to cygpath to sanitize input.



23
24
25
26
# File 'lib/beaker/host/windows/file.rb', line 23

def chown(user, path, recursive=false)
  cygpath = execute("cygpath -u #{path}")
  super(user, cygpath, recursive)
end

#file_exist?(path) ⇒ Boolean

Returns:

  • (Boolean)


74
75
76
77
# File 'lib/beaker/host/windows/file.rb', line 74

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

#ls_ld(path) ⇒ Object

Note:

Cygwin’s ‘ls_ld` implementation does not support windows-, DOS-, or mixed-style paths, only UNIX/POSIX-style. This method simply wraps the normal Host#ls_ld call with a call to cygpath to sanitize input.



46
47
48
49
# File 'lib/beaker/host/windows/file.rb', line 46

def ls_ld(path)
  cygpath = execute("cygpath -u #{path}")
  super(cygpath)
end

#path_split(paths) ⇒ Object



70
71
72
# File 'lib/beaker/host/windows/file.rb', line 70

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



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/beaker/host/windows/file.rb', line 58

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