Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,10 @@ function Expand-Archive

BEGIN
{
$isVerbose = $psboundparameters.ContainsKey("Verbose")
$isConfirm = $psboundparameters.ContainsKey("Confirm")

[boolean] $isVerbose = $PSBoundParameters.ContainsKey('Verbose') -and $PSBoundParameters['Verbose']
[boolean] $isConfirm = $PSBoundParameters.ContainsKey('Confirm') -and $PSBoundParameters['Confirm']
[boolean] $isWhatIf = $PSBoundParameters.ContainsKey('WhatIf') -and $PSBoundParameters['WhatIf']

$isDestinationPathProvided = $true
if($DestinationPath -eq [string]::Empty)
{
Expand Down Expand Up @@ -322,7 +323,7 @@ function Expand-Archive
}
else
{
$createdItem = New-Item -Path $DestinationPath -ItemType Directory -Confirm:$isConfirm -Verbose:$isVerbose -ErrorAction Stop
$createdItem = New-Item -Path $DestinationPath -ItemType Directory -Confirm:$isConfirm -Verbose:$isVerbose -WhatIf:$isWhatIf -ErrorAction Stop
if($createdItem -ne $null -and $createdItem.PSProvider.Name -ne "FileSystem")
{
Remove-Item "$DestinationPath" -Force -Recurse -ErrorAction SilentlyContinue
Expand Down Expand Up @@ -397,11 +398,11 @@ function Expand-Archive

if(!$destinationPathExists)
{
New-Item -Path $resolvedDestinationPath -ItemType Directory -Confirm:$isConfirm -Verbose:$isVerbose -ErrorAction Stop | Out-Null
New-Item -Path $resolvedDestinationPath -ItemType Directory -Confirm:$isConfirm -Verbose:$isVerbose -WhatIf:$isWhatIf -ErrorAction Stop | Out-Null
}
}

ExpandArchiveHelper $resolvedSourcePaths $resolvedDestinationPath ([ref]$expandedItems) $Force $isVerbose $isConfirm
ExpandArchiveHelper $resolvedSourcePaths $resolvedDestinationPath ([ref]$expandedItems) $Force $isVerbose $isConfirm $isWhatIf

$isArchiveFileProcessingComplete = $true
}
Expand Down Expand Up @@ -933,7 +934,8 @@ function ExpandArchiveHelper
[ref] $expandedItems,
[boolean] $force,
[boolean] $isVerbose,
[boolean] $isConfirm
[boolean] $isConfirm,
[boolean] $isWhatIf
)

Add-CompressionAssemblies
Expand Down Expand Up @@ -1022,7 +1024,7 @@ function ExpandArchiveHelper
# then it means that user has added this directory by other means.
if($pathExists -eq $false)
{
New-Item $currentArchiveEntryPath -Type Directory -Confirm:$isConfirm | Out-Null
New-Item $currentArchiveEntryPath -Type Directory -Confirm:$isConfirm -WhatIf:$isWhatIf| Out-Null

if(Test-Path -LiteralPath $currentArchiveEntryPath -PathType Container)
{
Expand All @@ -1046,7 +1048,7 @@ function ExpandArchiveHelper
# note that if any ancestor of this directory doesn't exist, we don't recursively create each one as New-Item
# takes care of this already, so only one DirectoryInfo is returned instead of one for each parent directory
# that only contains directories
New-Item $currentArchiveEntryFileInfo.DirectoryName -Type Directory -Confirm:$isConfirm | Out-Null
New-Item $currentArchiveEntryFileInfo.DirectoryName -Type Directory -Confirm:$isConfirm -WhatIf:$isWhatIf | Out-Null

if(!(Test-Path -LiteralPath $currentArchiveEntryFileInfo.DirectoryName -PathType Container))
{
Expand All @@ -1068,7 +1070,7 @@ function ExpandArchiveHelper
{
if($force)
{
Remove-Item -LiteralPath $currentArchiveEntryFileInfo.FullName -Force -ErrorVariable ev -Verbose:$isVerbose -Confirm:$isConfirm
Remove-Item -LiteralPath $currentArchiveEntryFileInfo.FullName -Force -ErrorVariable ev -Verbose:$isVerbose -Confirm:$isConfirm -WhatIf:$isWhatIf
if($ev -ne $null)
{
$hasNonTerminatingError = $true
Expand Down