From d23a5fddc70641621cfbaae72d7c15cb09caef8a Mon Sep 17 00:00:00 2001 From: James Truher Date: Thu, 21 Jul 2016 11:13:47 -0700 Subject: [PATCH] fix Archive module to work correctly when the DirectorySeparatorChar is "/" rather than use either "/" or "\", just use [io.path]::DirectorySeparatorChar --- .../Microsoft.PowerShell.Archive.psm1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Modules/Shared/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 b/src/Modules/Shared/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 index e179118c24..56daf78d8c 100644 --- a/src/Modules/Shared/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 +++ b/src/Modules/Shared/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1 @@ -662,13 +662,13 @@ function CompressSingleDirHelper } else { - $modifiedSourceDirFullName = $sourceDirFullName + "\" + $modifiedSourceDirFullName = $sourceDirFullName + ([io.path]::DirectorySeparatorChar) } } else { $sourceDirFullName = $sourceDirPath - $modifiedSourceDirFullName = $sourceDirFullName + "\" + $modifiedSourceDirFullName = $sourceDirFullName + ([io.path]::DirectorySeparatorChar) } $dirContents = Get-ChildItem -LiteralPath $sourceDirPath -Recurse @@ -688,7 +688,7 @@ function CompressSingleDirHelper $files = $currentContent.GetFiles() if($files.Count -eq 0) { - $subDirFiles.Add($currentContent.FullName + "\") + $subDirFiles.Add($currentContent.FullName + ([io.path]::DirectorySeparatorChar)) } } } @@ -780,7 +780,7 @@ function ZipArchiveHelper # If a directory needs to be added to an archive file, # by convention the .Net API's expect the path of the diretcory # to end with '\' to detect the path as an directory. - if(!$relativeFilePath.EndsWith("\", [StringComparison]::OrdinalIgnoreCase)) + if(!$relativeFilePath.EndsWith(([io.path]::DirectorySeparatorChar), [StringComparison]::OrdinalIgnoreCase)) { try { @@ -951,7 +951,7 @@ function ExpandArchiveHelper # The current archive entry is an empty directory # The FullName of the Archive Entry representing a directory would end with a trailing '\'. if($extension -eq [string]::Empty -and - $currentArchiveEntryPath.EndsWith("\", [StringComparison]::OrdinalIgnoreCase)) + $currentArchiveEntryPath.EndsWith(([io.path]::DirectorySeparatorChar), [StringComparison]::OrdinalIgnoreCase)) { $pathExists = Test-Path -LiteralPath $currentArchiveEntryPath