Skip to content

Commit d23a5fd

Browse files
committed
fix Archive module to work correctly when the DirectorySeparatorChar is "/"
rather than use either "/" or "\", just use [io.path]::DirectorySeparatorChar
1 parent 176f9fb commit d23a5fd

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/Modules/Shared/Microsoft.PowerShell.Archive/Microsoft.PowerShell.Archive.psm1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,13 @@ function CompressSingleDirHelper
662662
}
663663
else
664664
{
665-
$modifiedSourceDirFullName = $sourceDirFullName + "\"
665+
$modifiedSourceDirFullName = $sourceDirFullName + ([io.path]::DirectorySeparatorChar)
666666
}
667667
}
668668
else
669669
{
670670
$sourceDirFullName = $sourceDirPath
671-
$modifiedSourceDirFullName = $sourceDirFullName + "\"
671+
$modifiedSourceDirFullName = $sourceDirFullName + ([io.path]::DirectorySeparatorChar)
672672
}
673673

674674
$dirContents = Get-ChildItem -LiteralPath $sourceDirPath -Recurse
@@ -688,7 +688,7 @@ function CompressSingleDirHelper
688688
$files = $currentContent.GetFiles()
689689
if($files.Count -eq 0)
690690
{
691-
$subDirFiles.Add($currentContent.FullName + "\")
691+
$subDirFiles.Add($currentContent.FullName + ([io.path]::DirectorySeparatorChar))
692692
}
693693
}
694694
}
@@ -780,7 +780,7 @@ function ZipArchiveHelper
780780
# If a directory needs to be added to an archive file,
781781
# by convention the .Net API's expect the path of the diretcory
782782
# to end with '\' to detect the path as an directory.
783-
if(!$relativeFilePath.EndsWith("\", [StringComparison]::OrdinalIgnoreCase))
783+
if(!$relativeFilePath.EndsWith(([io.path]::DirectorySeparatorChar), [StringComparison]::OrdinalIgnoreCase))
784784
{
785785
try
786786
{
@@ -951,7 +951,7 @@ function ExpandArchiveHelper
951951
# The current archive entry is an empty directory
952952
# The FullName of the Archive Entry representing a directory would end with a trailing '\'.
953953
if($extension -eq [string]::Empty -and
954-
$currentArchiveEntryPath.EndsWith("\", [StringComparison]::OrdinalIgnoreCase))
954+
$currentArchiveEntryPath.EndsWith(([io.path]::DirectorySeparatorChar), [StringComparison]::OrdinalIgnoreCase))
955955
{
956956
$pathExists = Test-Path -LiteralPath $currentArchiveEntryPath
957957

0 commit comments

Comments
 (0)