vcpkg/scripts/findFileRecursivelyUp.ps1

18 lines
513 B
PowerShell
Raw Normal View History

[CmdletBinding()]
param(
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory=$true)][string]$startingDir,
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory=$true)][string]$filename
)
$ErrorActionPreference = "Stop"
$currentDir = $startingDir
while (!($currentDir -eq "") -and !(Test-Path "$currentDir\$filename"))
{
2017-02-24 07:57:22 +08:00
Write-Verbose "Examining $currentDir for $filename"
$currentDir = Split-path $currentDir -Parent
}
2017-02-24 07:57:22 +08:00
Write-Verbose "Examining $currentDir for $filename - Found"
return $currentDir