diff --git a/cmake/resolve_symlinks.ps1 b/cmake/resolve_symlinks.ps1 index 3d10d28..59d58aa 100644 --- a/cmake/resolve_symlinks.ps1 +++ b/cmake/resolve_symlinks.ps1 @@ -6,22 +6,15 @@ function Resolve-Symlinks { [string] $Path ) - [string] $separator = '/' - [string[]] $parts = $Path.Split($separator) - - [string] $realPath = '' - foreach ($part in $parts) { - if ($realPath -and !$realPath.EndsWith($separator)) { - $realPath += $separator - } - $realPath += $part - $item = Get-Item $realPath - if ($item.Target) { - $realPath = $item.Target.Replace('\', '/') - } + $Private:Item = Get-Item -LiteralPath $Path + if ([string]::IsNullOrEmpty($Private:Item.Target)) { + $Private:Parent = Resolve-Symlinks $Private:Item.Parent + return Join-Path $Private:Parent $Private:Item.Name + } + else { + return $Private:Item.Target } - $realPath } -$path=Resolve-Symlinks -Path $args[0] +$path = Resolve-Symlinks -Path $args[0] Write-Host $path