Merge pull request #5495 from jfbibeau/windows_unc_paths

Proposed fix for #4815 - Windows UNC path to allow > 256 characters
This commit is contained in:
Seth Vargo 2015-05-06 14:06:38 -07:00
commit 3b10a3165a
3 changed files with 18 additions and 1 deletions

View File

@ -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?

View File

@ -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",
folder[:hostpath]]
hostpath]
args << "--transient" if folder.key?(:transient) && folder[:transient]
# Enable symlinks on the shared folder

View File

@ -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