<# FPS:Containers:Make:Private:Format-FileHandle:ACTIVE
#>
function Format-FileHandle {
<#
.DESCRIPTION
Module: Make
Private CmdLet:
Format-FileHandle.ps1
Has Dependencies: Yes
Returns the logical file handle for the FQ filename sent
in the form {MetaData:profile}
format.
.EXAMPLE
if (Push-NeededFor Format-FileHandle) { . (Get-ActiveFileNm -PS1 Format-FileHandle) }
$FQFn =
"C:\Users\jimdi\OneDrive\FPS\Containers\Aloha-P1\Make\Make\Private\Format-Changes.ps1"
Format-FileHandle -FQFn $FQFn
Returns {Source:Aloha-P1:Make:Private:Format-Changes}
.CC
[2024.11.16 JD] Original code release. Decreased the code
footprint by 75% by using this Cmd
.NOTES
#>
[CmdletBinding()]
param(
[Parameter(Mandatory=$false)] [string]$FQFn #
Title of the list
)
$SpFQFn = $FQFn.split('\')
# The source could be formatted in network format, so
just do a check against runtime - then assume Source on the else
if ($FQFn -like ($global:pro_CIBase.RuntimeRoot+'\*')) {
$RtnStr = '{Runtime:'
} else {
$RtnStr = '{Source:'
}
$FPSFound, $Segment = $false, ''
$Ver = $global:pro_CI.Family+'-'+$global:pro_CI.Patch
for ($ptr=0; $ptr -lt $SpFQFn.length; $ptr++) {
if ($SpFQFn[$ptr] -eq 'FPS') { $FPSFound = $true; $ptr++ }
if ($FPSFound) {
if ($Segment -eq "Containers") {
if ($ptr -eq ($SpFQFn.length-1)) { # At the file level
$RtnStr += ":"+$SpFQFn[$ptr].replace(".ps1","")+"}"
} else {
if ($RtnStr.indexOf($SpFQFn[$ptr]) -le 0) { $RtnStr += ":"+$SpFQFn[$ptr] }
}
}
if ($Segment -eq "Metadata") {
if ($ptr -eq ($SpFQFn.length-1)) { # At the file level
$RtnStr += ":"+$SpFQFn[$ptr].replace(".ps1","")+"}"
}
}
if ($SpFQFn[$ptr] -in ("Containers","Metadata")) {
$Segment = $SpFQFn[$ptr]
if ($Segment -eq "Metadata") {
$RtnStr += ":"+$SpFQFn[$ptr] } # Only add Metadata to the rtnstr, Containers is not necessary
}
}
}
$RtnStr
}