module Windows::File

Public Instance Methods

chgrp(group, path, recursive = false) click to toggle source

(see {Beaker::Host::Unix::File#chgrp}) @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.
Calls superclass method
# 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) click to toggle source

Not needed on windows

# File lib/beaker/host/windows/file.rb, line 39
def chmod(mod, path, recursive = false); end
chown(user, path, recursive = false) click to toggle source

(see {Beaker::Host::Unix::File#chown}) @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.
Calls superclass method
# 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) click to toggle source
# File lib/beaker/host/windows/file.rb, line 76
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) click to toggle source

(see {Beaker::Host::Unix::File#ls_ld}) @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.
Calls superclass method
# File lib/beaker/host/windows/file.rb, line 46
def ls_ld(path)
  cygpath = execute("cygpath -u #{path}")
  super(cygpath)
end
path_split(paths) click to toggle source
# File lib/beaker/host/windows/file.rb, line 72
def path_split(paths)
  paths.split(';')
end
scp_path(path) click to toggle source

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

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

@param [String] path Path to be changed

@return [String] Path updated for use by SCP

# File lib/beaker/host/windows/file.rb, line 58
def scp_path(path)
  case determine_ssh_server
  when :bitvise
    # swap out separators
    path.gsub('\\', scp_separator)
  when :openssh
    path
  when :win32_openssh
    path.tr('\\', '/')
  else
    raise ArgumentError, "windows/file.rb:scp_path: ssh server not recognized: '#{determine_ssh_server}'"
  end
end
system_temp_path() click to toggle source
# 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.delete("\n") + '\\TEMP'
end
tmpdir(name = '') click to toggle source
# File lib/beaker/host/windows/file.rb, line 8
def tmpdir(name = '')
  execute("cygpath -m $(mktemp -td #{name}.XXXXXX)")
end
tmpfile(name = '', extension = nil) click to toggle source
# File lib/beaker/host/windows/file.rb, line 4
def tmpfile(name = '', extension = nil)
  execute("cygpath -m $(mktemp -t #{name}.XXXXXX#{extension})")
end