aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-11-16 02:01:50 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-11-16 02:02:00 -0800
commitb2e1dc3e5a4224bd06f1aaa52c87f5c8939787ae (patch)
tree67b103eaea29ab3f6d4024242c6565422cfb30e8
parent52ef8c72804f70681e4ec7c9deaee171222d0fea (diff)
downloadvcpkg-b2e1dc3e5a4224bd06f1aaa52c87f5c8939787ae.tar.gz
vcpkg-b2e1dc3e5a4224bd06f1aaa52c87f5c8939787ae.zip
Use temp-and-rename pattern for extracting
-rw-r--r--scripts/VcpkgPowershellUtils.ps113
-rw-r--r--scripts/fetchDependency.ps12
2 files changed, 11 insertions, 4 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1
index c7447b383..12eacec96 100644
--- a/scripts/VcpkgPowershellUtils.ps1
+++ b/scripts/VcpkgPowershellUtils.ps1
@@ -144,16 +144,20 @@ function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$file,
[Parameter(Mandatory=$true)][string]$destination)
{
vcpkgCreateDirectory $destination
+ $baseName = (Get-ChildItem .\downloads\cmake-3.9.5-win32-x86.zip).BaseName
+ $destinationPartial = "$destination\$baseName-partially_extracted"
+ vcpkgRemoveDirectory $destinationPartial
+ vcpkgCreateDirectory $destinationPartial
if (vcpkgHasCommand -commandName 'Microsoft.PowerShell.Archive\Expand-Archive')
{
Write-Verbose("Extracting with Microsoft.PowerShell.Archive\Expand-Archive")
- Microsoft.PowerShell.Archive\Expand-Archive -path $file -destinationpath $destination
+ Microsoft.PowerShell.Archive\Expand-Archive -path $file -destinationpath $destinationPartial
}
elseif (vcpkgHasCommand -commandName 'Pscx\Expand-Archive')
{
Write-Verbose("Extracting with Pscx\Expand-Archive")
- Pscx\Expand-Archive -path $file -OutputPath $destination
+ Pscx\Expand-Archive -path $file -OutputPath $destinationPartial
}
else
{
@@ -163,9 +167,12 @@ function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$file,
foreach($item in $zip.items())
{
# Piping to Out-Null is used to block until finished
- $shell.Namespace($destination).copyhere($item) | Out-Null
+ $shell.Namespace($destinationPartial).copyhere($item) | Out-Null
}
}
+
+ Move-Item -Path "$destinationPartial\*" -Destination $destination
+ vcpkgRemoveDirectory $destinationPartial
}
function vcpkgInvokeCommand()
diff --git a/scripts/fetchDependency.ps1 b/scripts/fetchDependency.ps1
index 8ea69e488..2cc782feb 100644
--- a/scripts/fetchDependency.ps1
+++ b/scripts/fetchDependency.ps1
@@ -89,7 +89,7 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
}
elseif($extractionType -eq $ExtractionType_ZIP)
{
- if (-not (Test-Path $executableFromDownload)) # consider renaming the extraction folder to make sure the extraction finished
+ if (-not (Test-Path $executableFromDownload))
{
vcpkgExtractFile -File $downloadPath -Destination $extractionFolder
}