2021-02-18 15:53:32 +00:00
|
|
|
[CmdletBinding()]param(
|
2021-02-19 20:19:42 +00:00
|
|
|
[switch]$Expand,
|
2021-02-18 15:53:32 +00:00
|
|
|
[Parameter(ValueFromPipeline,ValueFromPipelineByPropertyName,Position=0)]
|
|
|
|
[Alias("FullName")]
|
|
|
|
[string[]]$Path
|
|
|
|
)
|
|
|
|
process {
|
|
|
|
foreach( $local:p in $Path ) {
|
|
|
|
switch( $p[0] ) {
|
|
|
|
'@' { $p = Join-Path $MyPSScriptRoot $p.Substring(1) }
|
|
|
|
'~' {
|
|
|
|
if( $p -match '^~[^/]*' ) {
|
|
|
|
$local:m = $Matches[0]
|
2021-02-20 00:22:46 +00:00
|
|
|
$p = $p -replace "^$m",((Get-Item -Force $m).FullName)
|
2021-02-18 15:53:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-29 23:26:39 +00:00
|
|
|
|
2022-02-04 00:08:16 +00:00
|
|
|
# clean end of path from DirectorySeparatorChars
|
|
|
|
$p = $p -replace '[/\\]+$',''
|
|
|
|
|
2021-03-06 23:10:28 +00:00
|
|
|
$p = $p -replace '#C-','#C-#' -replace '\*','#C-A#' -replace '\?','#C-Q#'
|
2021-02-18 15:53:32 +00:00
|
|
|
if([System.IO.Path]::IsPathRooted($p)){
|
2021-02-19 20:19:42 +00:00
|
|
|
$p = [System.IO.Path]::GetFullPath($p)
|
2021-02-18 15:53:32 +00:00
|
|
|
}else{
|
2021-02-19 20:19:42 +00:00
|
|
|
$p = [System.IO.Path]::GetFullPath((Join-Path $PWD $p))
|
2021-02-18 15:53:32 +00:00
|
|
|
}
|
2021-03-06 23:10:28 +00:00
|
|
|
$p = $p -replace '#C-A#','*' -replace '#C-Q#','?' -replace '#C-#','#C-'
|
2021-02-19 20:19:42 +00:00
|
|
|
|
2021-03-23 05:06:49 +00:00
|
|
|
if( $p -match '\*|\?' -and $Expand ) {
|
|
|
|
$p = $p | Where-Object { Test-Path $_ } |
|
|
|
|
Get-Item -Force |
|
|
|
|
Select-Object -ExpandProperty FullName
|
2021-02-19 20:19:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$p
|
2021-02-18 15:53:32 +00:00
|
|
|
}
|
2021-01-29 23:26:39 +00:00
|
|
|
}
|