moved function to platform utils, added unit test as per @sethvargo
This commit is contained in:
parent
7d17574a76
commit
415837c544
|
@ -144,6 +144,13 @@ module Vagrant
|
|||
path
|
||||
end
|
||||
|
||||
# Converts a given path to UNC format by adding a prefix and converting slashes.
|
||||
# @param [String] path Path to convert to UNC for Windows
|
||||
# @return [String]
|
||||
def windows_unc_path(path)
|
||||
"//?/" + path.gsub("/", "\\")
|
||||
end
|
||||
|
||||
# Returns a boolean noting whether the terminal supports color.
|
||||
# output.
|
||||
def terminal_supports_colors?
|
||||
|
|
|
@ -496,10 +496,14 @@ module VagrantPlugins
|
|||
|
||||
def share_folders(folders)
|
||||
folders.each do |folder|
|
||||
hostpath = folder[:hostpath]
|
||||
if Vagrant::Util::Platform.windows?
|
||||
hostpath = Vagrant::Util::Platform.windows_unc_path(hostpath)
|
||||
end
|
||||
args = ["--name",
|
||||
folder[:name],
|
||||
"--hostpath",
|
||||
Vagrant::Util::Platform.windows? ? ("//?/" + File.expand_path(folder[:hostpath])).gsub("/","\\") : folder[:hostpath]]
|
||||
hostpath]
|
||||
args << "--transient" if folder.key?(:transient) && folder[:transient]
|
||||
|
||||
# Enable symlinks on the shared folder
|
||||
|
|
|
@ -10,4 +10,10 @@ describe Vagrant::Util::Platform do
|
|||
expect(described_class.fs_real_path("c:/foo").to_s).to eql("C:/foo")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#windows_unc_path" do
|
||||
it "correctly converts a path" do
|
||||
expect(described_class.windows_unc_path("c:/foo").to_s).to eql("//?/c:\\foo")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue