aboutsummaryrefslogtreecommitdiff
path: root/scripts/VcpkgPowershellUtils.ps1
diff options
context:
space:
mode:
authorAlexander Karatarakis <alkarata@microsoft.com>2017-11-17 01:23:14 -0800
committerAlexander Karatarakis <alkarata@microsoft.com>2017-11-17 01:23:14 -0800
commit6290155eaaff1bd70ec9a893b090adea473effa8 (patch)
tree784ea908c7c13da2e76563bbea413d7049a98d21 /scripts/VcpkgPowershellUtils.ps1
parentc4ca996583c61d311bf15c40dbbb261ce5f59047 (diff)
downloadvcpkg-6290155eaaff1bd70ec9a893b090adea473effa8.tar.gz
vcpkg-6290155eaaff1bd70ec9a893b090adea473effa8.zip
[vcpkgExtractFile] Fix partial dir name. Special case 1-item zips
- If the zip contains a single item, pull that up a directory - If the zip contains multiple items, place that in a directory on of the same name as the zip
Diffstat (limited to 'scripts/VcpkgPowershellUtils.ps1')
-rw-r--r--scripts/VcpkgPowershellUtils.ps123
1 files changed, 17 insertions, 6 deletions
diff --git a/scripts/VcpkgPowershellUtils.ps1 b/scripts/VcpkgPowershellUtils.ps1
index 12eacec96..0b1a35262 100644
--- a/scripts/VcpkgPowershellUtils.ps1
+++ b/scripts/VcpkgPowershellUtils.ps1
@@ -141,11 +141,13 @@ function vcpkgDownloadFile( [Parameter(Mandatory=$true)][string]$url,
}
function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$file,
- [Parameter(Mandatory=$true)][string]$destination)
+ [Parameter(Mandatory=$true)][string]$destinationDir)
{
- vcpkgCreateDirectory $destination
- $baseName = (Get-ChildItem .\downloads\cmake-3.9.5-win32-x86.zip).BaseName
- $destinationPartial = "$destination\$baseName-partially_extracted"
+ $parentPath = split-path -parent $destinationDir
+ vcpkgCreateDirectory $parentPath
+ $baseName = (Get-ChildItem $file).BaseName
+ $destinationPartial = "$destinationDir\$baseName-partially_extracted"
+
vcpkgRemoveDirectory $destinationPartial
vcpkgCreateDirectory $destinationPartial
@@ -171,8 +173,17 @@ function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$file,
}
}
- Move-Item -Path "$destinationPartial\*" -Destination $destination
- vcpkgRemoveDirectory $destinationPartial
+ $hasASingleItem = (Get-ChildItem $destinationPartial | Measure-Object).Count -eq 1;
+
+ if ($hasASingleItem)
+ {
+ Move-Item -Path "$destinationPartial\*" -Destination $destinationDir
+ vcpkgRemoveDirectory $destinationPartial
+ }
+ else
+ {
+ Rename-Item -Path $destinationPartial -NewName $baseName
+ }
}
function vcpkgInvokeCommand()