From 08d2ff3d682836ca0e3ca9b0d2fe86c7d90ba1b8 Mon Sep 17 00:00:00 2001 From: Thomas Malkewitz Date: Mon, 17 Dec 2018 14:11:54 -0500 Subject: [PATCH] Bug fix #83. --- WinSCP/Private/Format-WinSCPPathString.ps1 | 3 ++- WinSCP/Public/Move-WinSCPItem.ps1 | 7 ++++--- WinSCP/Public/Test-WinSCPPath.ps1 | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/WinSCP/Private/Format-WinSCPPathString.ps1 b/WinSCP/Private/Format-WinSCPPathString.ps1 index 9b36c52..2aa94c6 100644 --- a/WinSCP/Private/Format-WinSCPPathString.ps1 +++ b/WinSCP/Private/Format-WinSCPPathString.ps1 @@ -47,7 +47,8 @@ function Format-WinSCPPathString { ) } - if ($item.ToCharArray()[0] -ne [System.IO.Path]::AltDirectorySeparatorChar) { + $itemCharArray = $item.ToCharArray() + if ($itemCharArray[0] -ne [System.IO.Path]::AltDirectorySeparatorChar -and $itemCharArray[0] -ne '.') { $item = [System.IO.Path]::AltDirectorySeparatorChar + $item } diff --git a/WinSCP/Public/Move-WinSCPItem.ps1 b/WinSCP/Public/Move-WinSCPItem.ps1 index b5f6fc9..442d367 100644 --- a/WinSCP/Public/Move-WinSCPItem.ps1 +++ b/WinSCP/Public/Move-WinSCPItem.ps1 @@ -26,7 +26,6 @@ [Parameter( Mandatory = $true, - Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true )] @@ -56,11 +55,13 @@ $pathValue ) if ($shouldProcess) { - if ($null -ne $destinationInfo) { + if ($null -ne $destinationInfo -and $destinationInfo.IsDirectory) { $leaf = Split-Path -Path $pathValue -Leaf $destinationPath = $WinSCPSession.CombinePaths( - $Destination, $leaf + $destinationInfo.FullName, $leaf ) + } else { + $destinationPath = $Destination } if (( Test-WinSCPPath -WinSCPSession $WinSCPSession -Path $destinationPath ) -and $Force.IsPresent) { diff --git a/WinSCP/Public/Test-WinSCPPath.ps1 b/WinSCP/Public/Test-WinSCPPath.ps1 index 080ab04..bc80b95 100644 --- a/WinSCP/Public/Test-WinSCPPath.ps1 +++ b/WinSCP/Public/Test-WinSCPPath.ps1 @@ -31,7 +31,7 @@ ) process { - foreach($pathValue in (Format-WinSCPPathString -Path $($Path))) { + foreach($pathValue in (Format-WinSCPPathString -Path $Path)) { try { $output = $WinSCPSession.FileExists( $pathValue