diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/VcpkgPowershellUtils.ps1 | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1 index bed78b198..b73361fd1 100644 --- a/scripts/VcpkgPowershellUtils.ps1 +++ b/scripts/VcpkgPowershellUtils.ps1 @@ -25,16 +25,29 @@ function vcpkgCreateParentDirectoryIfNotExists([Parameter(Mandatory=$true)][stri } } -function vcpkgRemoveItem([Parameter(Mandatory=$true)][string]$dirPath) +function vcpkgIsDirectory([Parameter(Mandatory=$true)][string]$path) { - if ([string]::IsNullOrEmpty($dirPath)) + return (Get-Item $path) -is [System.IO.DirectoryInfo] +} + +function vcpkgRemoveItem([Parameter(Mandatory=$true)][string]$path) +{ + if ([string]::IsNullOrEmpty($path)) { return } - if (Test-Path $dirPath) + if (Test-Path $path) { - Remove-Item $dirPath -Recurse -Force + # Remove-Item -Recurse occasionally fails. This is a workaround + if (vcpkgIsDirectory $path) + { + & cmd.exe /c rd /s /q $path + } + else + { + Remove-Item $path -Force + } } } |
