aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2018-02-14 17:08:52 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2018-02-20 16:58:19 -0800
commit2f6cf768e54a155c282a7b490027ceb7be245fbf (patch)
treef1608cc7d601d4fc6afa54072c3ac2b1926965e3 /scripts
parent3daa3e8f303eaa89ff3bce90a1faa4752c3474fe (diff)
downloadvcpkg-2f6cf768e54a155c282a7b490027ceb7be245fbf.tar.gz
vcpkg-2f6cf768e54a155c282a7b490027ceb7be245fbf.zip
Improve vcpkgRemoveItem
Diffstat (limited to 'scripts')
-rw-r--r--scripts/VcpkgPowershellUtils.ps121
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
+ }
}
}