Properly expand cygwin paths to Windows path for vboxmanage

This commit is contained in:
Mitchell Hashimoto 2013-04-06 22:06:33 -07:00
parent 96ebd3e8f7
commit 373a1d8633
6 changed files with 9 additions and 40 deletions

View File

@ -53,6 +53,7 @@ BUG FIXES:
- Cygwin will always output color by default. Specify `--no-color` to
override this.
- Assume Cygwin has a TTY for asking for input. [GH-1430]
- Expand Cygwin paths to Windows paths for calls to VBoxManage.
## 1.1.6 (April 3, 2013)

View File

@ -1,5 +1,4 @@
require 'rbconfig'
require 'tempfile'
require "vagrant/util/subprocess"
@ -8,14 +7,6 @@ module Vagrant
# This class just contains some platform checking code.
class Platform
class << self
def tiger?
platform.include?("darwin8")
end
def leopard?
platform.include?("darwin9")
end
def cygwin?
return true if ENV["VAGRANT_DETECTED_OS"] &&
ENV["VAGRANT_DETECTED_OS"].downcase.include?("cygwin")
@ -37,32 +28,14 @@ module Vagrant
false
end
# Returns boolean noting whether this is a 64-bit CPU. This
# is not 100% accurate and there could easily be false negatives.
# This takes any path and converts it to a full-length Windows
# path on Windows machines in Cygwin.
#
# @return [Boolean]
def bit64?
["x86_64", "amd64"].include?(RbConfig::CONFIG["host_cpu"])
end
# Returns boolean noting whether this is a 32-bit CPU. This
# can easily throw false positives since it relies on {#bit64?}.
#
# @return [Boolean]
def bit32?
!bit64?
end
# This takes as input a path as a string and converts it into
# a platform-friendly version of the path. This is most important
# when using the path in shell environments with Cygwin.
#
# @param [String] path
# @return [String]
def platform_path(path)
def cygwin_windows_path(path)
return path if !cygwin?
process = Subprocess.execute("cygpath", "-u", path.to_s)
process = Subprocess.execute("cygpath", "-w", "-l", "-a", path.to_s)
process.stdout.chomp
end
@ -76,11 +49,6 @@ module Vagrant
true
end
def tar_file_options
# create, write only, fail if the file exists, binary if windows
File::WRONLY | File::EXCL | File::CREAT | (windows? ? File::BINARY : 0)
end
def platform
RbConfig::CONFIG["host_os"].downcase
end

View File

@ -45,7 +45,7 @@ module VagrantPlugins
# and break out
vboxmanage = "#{path}VBoxManage.exe"
if File.file?(vboxmanage)
@vboxmanage_path = Vagrant::Util::Platform.platform_path(vboxmanage)
@vboxmanage_path = Vagrant::Util::Platform.cygwin_windows_path(vboxmanage)
break
end
end

View File

@ -159,7 +159,7 @@ module VagrantPlugins
end
def import(ovf)
ovf = Vagrant::Util::Platform.platform_path(ovf)
ovf = Vagrant::Util::Platform.cygwin_windows_path(ovf)
output = ""
total = ""

View File

@ -159,7 +159,7 @@ module VagrantPlugins
end
def import(ovf)
ovf = Vagrant::Util::Platform.platform_path(ovf)
ovf = Vagrant::Util::Platform.cygwin_windows_path(ovf)
output = ""
total = ""

View File

@ -157,7 +157,7 @@ module VagrantPlugins
end
def import(ovf)
ovf = Vagrant::Util::Platform.platform_path(ovf)
ovf = Vagrant::Util::Platform.cygwin_windows_path(ovf)
output = ""
total = ""