Rework vcpkgExtractFile (powershell)

This commit is contained in:
Alexander Karatarakis 2017-11-27 00:42:21 -08:00
parent c4c079f86e
commit 2c914ff05a
2 changed files with 7 additions and 8 deletions

View File

@ -19,7 +19,7 @@ function vcpkgCreateParentDirectoryIfNotExists([Parameter(Mandatory=$true)][stri
return
}
if (!(Test-Path $dirPath))
if (!(Test-Path $parentDir))
{
New-Item -ItemType Directory -Path $parentDir | Out-Null
}
@ -157,9 +157,7 @@ function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$file,
[Parameter(Mandatory=$true)][string]$destinationDir)
{
vcpkgCreateParentDirectoryIfNotExists $destinationDir
$baseName = (Get-ChildItem $file).BaseName
$destination = "$destinationDir\$baseName"
$destinationPartial = "$destination-partially_extracted"
$destinationPartial = "$destinationDir-partially_extracted"
vcpkgRemoveDirectory $destinationPartial
vcpkgCreateDirectoryIfNotExists $destinationPartial
@ -192,12 +190,12 @@ function vcpkgExtractFile( [Parameter(Mandatory=$true)][string]$file,
{
Move-Item -Path "$destinationPartial\*" -Destination $destinationDir
vcpkgRemoveDirectory $destinationPartial
return $destination
return $destinationDir
}
else
{
Rename-Item -Path $destinationPartial -NewName $baseName
return $destination
Move-Item -Path $destinationPartial -Destination $destinationDir
return $destinationDir
}
}

View File

@ -88,7 +88,8 @@ function SelectProgram([Parameter(Mandatory=$true)][string]$Dependency)
{
if (-not (Test-Path $executableFromDownload))
{
vcpkgExtractFile -File $downloadPath -DestinationDir $downloadsDir
$extractFolderName = (Get-ChildItem $downloadPath).BaseName
vcpkgExtractFile -File $downloadPath -DestinationDir "$downloadsDir\$extractFolderName"
}
}
elseif($extractionType -eq $ExtractionType_SELF_EXTRACTING_7Z)