synced_folders/rsync: convert to proper unix-style path [GH-3086]

This commit is contained in:
Mitchell Hashimoto 2014-03-09 18:21:30 -07:00
parent 59ae11bab3
commit 04a19e05ca
2 changed files with 22 additions and 13 deletions

View File

@ -50,20 +50,15 @@ module Vagrant
end
end
# This takes any path and converts it to a full-length Windows
# path on Windows machines in Cygwin.
# This takes any path and converts it from a Windows path to a
# Cygwin or msys style path.
#
# @param [String] path
# @return [String]
def cygwin_windows_path(path, **opts)
return path if !cygwin? && !opts[:force]
# First, no matter what process we use below, we must replace
# all "\" with "/", otherwise cygpath doesn't work.
path = path.gsub("\\", "/")
def cygwin_path(path)
begin
# First try the real cygpath
process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s)
process = Subprocess.execute("cygpath", "-u", "-a", path.to_s)
return process.stdout.chomp
rescue Errors::CommandUnavailableWindows
# Sometimes cygpath isn't available (msys). Instead, do what we
@ -77,6 +72,21 @@ module Vagrant
end
end
# This takes any path and converts it to a full-length Windows
# path on Windows machines in Cygwin.
#
# @return [String]
def cygwin_windows_path(path)
return path if !cygwin?
# Replace all "\" with "/", otherwise cygpath doesn't work.
path = path.gsub("\\", "/")
# Call out to cygpath and gather the result
process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s)
return process.stdout.chomp
end
# This checks if the filesystem is case sensitive. This is not a
# 100% correct check, since it is possible that the temporary
# directory runs a different filesystem than the root directory.

View File

@ -14,9 +14,8 @@ module VagrantPlugins
hostpath = Vagrant::Util::Platform.fs_real_path(hostpath).to_s
if Vagrant::Util::Platform.windows?
# rsync for Windows expects cygwin style paths
hostpath = Vagrant::Util::Platform.cygwin_windows_path(
hostpath, force: true)
# rsync for Windows expects cygwin style paths, always.
hostpath = Vagrant::Util::Platform.cygwin_path(hostpath)
end
# Make sure the host path ends with a "/" to avoid creating