mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 05:23:44 +08:00
28 lines
695 B
PowerShell
28 lines
695 B
PowerShell
function Resolve-Symlinks {
|
|
[CmdletBinding()]
|
|
[OutputType([string])]
|
|
param(
|
|
[Parameter(Position = 0, Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)]
|
|
[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('\', '/')
|
|
}
|
|
}
|
|
$realPath
|
|
}
|
|
|
|
$path=Resolve-Symlinks -Path $args[0]
|
|
Write-Host $path
|