Sha256: f7c7f2b2fdaf7a61a950407533c9211e7be9ebb8bc7804aec1e9a41596a9585e

Contents?: true

Size: 1.26 KB

Versions: 8

Compression:

Stored size: 1.26 KB

Contents

function Test-ReparsePoint([string]$path) {
  $file = Get-Item $path -Force -ea 0
  return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}


$MountPoint = [System.IO.Path]::GetFullPath("<%= options[:mount_point] %>")
$ShareName = "<%= options[:share_name] %>"

# https://github.com/BIAINC/vagrant-windows/issues/4
# Not sure why this works, but it does.

& net use $ShareName 2>&1 | Out-Null

Write-Debug "Attempting to mount $ShareName to $MountPoint"
if( (Test-Path "$MountPoint") -and (Test-ReparsePoint "$MountPoint") )
{
  Write-Debug "Junction already exists, so I will delete it"
  # Powershell refuses to delete junctions, oh well use cmd
  cmd /c rd "$MountPoint"

  if ( $LASTEXITCODE -ne 0 )
  {
    Write-Error "Failed to delete symbolic link at $MountPoint"
    exit 1
  }

} 
elseif(Test-Path $MountPoint) 
{
  Write-Debug "Mount point already exists and is not a symbolic link"
  exit 1
}

$BaseDirectory = [System.IO.Path]::GetDirectoryName($MountPoint)

if (-not (Test-Path $BaseDirectory))
{
  Write-Debug "Creating parent directory for mount point $BaseDirectory"
  New-Item $BaseDirectory -Type Directory -Force | Out-Null
}

cmd /c mklink /D "$MountPoint" "\\vmware-host\Shared Folders\$ShareName" | out-null

if ( $LASTEXITCODE -ne 0 )
{
  exit 1
}

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
vagrant-plugin-dummy-0.0.7 windows/scripts/mount_volume.vmware.ps1.erb
vagrant-plugin-dummy-0.0.6 windows/scripts/mount_volume.vmware.ps1.erb
vagrant-plugin-dummy-0.0.5 windows/scripts/mount_volume.vmware.ps1.erb
vagrant-plugin-dummy-0.0.4 windows/scripts/mount_volume.vmware.ps1.erb
vagrant-plugin-dummy-0.0.3 windows/scripts/mount_volume.vmware.ps1.erb
vagrant-plugin-dummy-0.0.1 windows/scripts/mount_volume.vmware.ps1.erb
vagrant-plugin-dummy-0.0.2 windows/scripts/mount_volume.vmware.ps1.erb
vagrant-windows-1.2.0 lib/vagrant-windows/scripts/mount_volume.vmware.ps1.erb