Class: VagrantPlugins::GuestLinux::Cap::SSHFSGetAbsolutePath

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-sshfs/cap/guest/linux/sshfs_get_absolute_path.rb

Class Method Summary collapse

Class Method Details

.sshfs_get_absolute_path(machine, path) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/vagrant-sshfs/cap/guest/linux/sshfs_get_absolute_path.rb', line 5

def self.sshfs_get_absolute_path(machine, path)
  abs_path = ""
  machine.communicate.execute("readlink -f #{path}", sudo: true) do |type, data|
    if type == :stdout
      abs_path = data
    end
  end

  if ! abs_path
    # If no real absolute path was detected then error out
    error_class = VagrantPlugins::SyncedFolderSSHFS::Errors::SSHFSGetAbsolutePathFailed
    raise error_class, path: path
  end

  # Chomp the string so that any trailing newlines are killed
  return abs_path.chomp
end