Surgo/scripts/helpers/ini.ps1

21 lines
590 B
PowerShell
Raw Normal View History

2024-04-07 22:32:49 -07:00
# This is meant to be used with build.ps1, and is not a standalone script.
function Get-IniContent { param([ string]$filePath )
$ini = @{}
$currentSection = $null
switch -regex -file $filePath
{
"^\[(.+)\]$" {
$currentSection = $matches[1].Trim()
$ini[$currentSection] = @{}
}
"^(.+?)\s*=\s*(.*)" {
$key, $value = $matches[1].Trim(), $matches[2].Trim()
if ($null -ne $currentSection) {
$ini[$currentSection][$key] = $value
}
}
}
return $ini
}