Private/PathUtilities.ps1
function Get-Segments { param ( [parameter(ValueFromPipeline)][string]$Path ) if (!$path) { return; } $parent = @(Split-Path -Path $Path -Parent | Get-Segments) $leaf = Split-Path -Path $Path -Leaf return $parent + $leaf } function Join-Segments { param ( [parameter(ValueFromPipeline)][string[]]$segments ) $segments = foreach ($segment in $segments) { Get-SanitizeSegment -Segment $segment } return $segments -join [System.IO.Path]::DirectorySeparatorChar } function Get-SanitizeSegment { param ( [parameter(ValueFromPipeline)][string]$Segment ) return $segment -replace '/|\\' } |