Use DefaultPathSeparator char instead of DefaultPathSeparatorString (#8082)
In: * SessionStateLocationAPIs * FileSystemProvider * LocationGlobber * NavigationProviderBase
This commit is contained in:
parent
66a4ab10a9
commit
ecb467c791
|
@ -545,7 +545,7 @@ namespace System.Management.Automation
|
||||||
// Remove the root slash since it is implied that the
|
// Remove the root slash since it is implied that the
|
||||||
// current working directory is relative to the root.
|
// current working directory is relative to the root.
|
||||||
if (!LocationGlobber.IsProviderDirectPath(path) &&
|
if (!LocationGlobber.IsProviderDirectPath(path) &&
|
||||||
path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal) &&
|
path.StartsWith(StringLiterals.DefaultPathSeparator) &&
|
||||||
!pathIsProviderQualifiedPath)
|
!pathIsProviderQualifiedPath)
|
||||||
{
|
{
|
||||||
path = path.Substring(1);
|
path = path.Substring(1);
|
||||||
|
|
|
@ -170,7 +170,7 @@ namespace System.Management.Automation
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The escape character used in the language.
|
/// The escape character used in the language.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal const string EscapeCharacter = "`";
|
internal const char EscapeCharacter = '`';
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default cmdlet adapter for cmdletization / cdxml modules
|
/// The default cmdlet adapter for cmdletization / cdxml modules
|
||||||
|
|
|
@ -1425,8 +1425,8 @@ namespace Microsoft.PowerShell.Commands
|
||||||
// Don't handle full paths, paths that the user is already trying to
|
// Don't handle full paths, paths that the user is already trying to
|
||||||
// filter, or paths they are trying to escape.
|
// filter, or paths they are trying to escape.
|
||||||
if ((!String.IsNullOrEmpty(filter)) ||
|
if ((!String.IsNullOrEmpty(filter)) ||
|
||||||
(path.Contains(StringLiterals.DefaultPathSeparatorString)) ||
|
(path.Contains(StringLiterals.DefaultPathSeparator, StringComparison.Ordinal)) ||
|
||||||
(path.Contains(StringLiterals.AlternatePathSeparatorString)) ||
|
(path.Contains(StringLiterals.AlternatePathSeparator, StringComparison.Ordinal)) ||
|
||||||
(path.Contains(StringLiterals.EscapeCharacter)))
|
(path.Contains(StringLiterals.EscapeCharacter)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -4814,13 +4814,13 @@ namespace Microsoft.PowerShell.Commands
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string originalPathComparison = path;
|
string originalPathComparison = path;
|
||||||
if (!originalPathComparison.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))
|
if (!originalPathComparison.EndsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
originalPathComparison += StringLiterals.DefaultPathSeparator;
|
originalPathComparison += StringLiterals.DefaultPathSeparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
string basePathComparison = basePath;
|
string basePathComparison = basePath;
|
||||||
if (!basePathComparison.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))
|
if (!basePathComparison.EndsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
basePathComparison += StringLiterals.DefaultPathSeparator;
|
basePathComparison += StringLiterals.DefaultPathSeparator;
|
||||||
}
|
}
|
||||||
|
@ -5018,7 +5018,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
// See if the base and the path are already the same. We resolve this to
|
// See if the base and the path are already the same. We resolve this to
|
||||||
// ..\Leaf, since resolving "." to "." doesn't offer much information.
|
// ..\Leaf, since resolving "." to "." doesn't offer much information.
|
||||||
if (String.Equals(path, basePath, StringComparison.OrdinalIgnoreCase) &&
|
if (String.Equals(path, basePath, StringComparison.OrdinalIgnoreCase) &&
|
||||||
(!originalPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
|
(!originalPath.EndsWith(StringLiterals.DefaultPathSeparator)))
|
||||||
{
|
{
|
||||||
string childName = GetChildName(path);
|
string childName = GetChildName(path);
|
||||||
result = MakePath("..", childName);
|
result = MakePath("..", childName);
|
||||||
|
@ -5065,7 +5065,7 @@ namespace Microsoft.PowerShell.Commands
|
||||||
if (!String.IsNullOrEmpty(commonBase))
|
if (!String.IsNullOrEmpty(commonBase))
|
||||||
{
|
{
|
||||||
if (String.Equals(path, commonBase, StringComparison.OrdinalIgnoreCase) &&
|
if (String.Equals(path, commonBase, StringComparison.OrdinalIgnoreCase) &&
|
||||||
(!path.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
|
(!path.EndsWith(StringLiterals.DefaultPathSeparator)))
|
||||||
{
|
{
|
||||||
string childName = GetChildName(path);
|
string childName = GetChildName(path);
|
||||||
result = MakePath("..", result);
|
result = MakePath("..", result);
|
||||||
|
|
|
@ -1436,8 +1436,8 @@ namespace System.Management.Automation
|
||||||
internal static bool IsSingleFileSystemAbsolutePath(string path)
|
internal static bool IsSingleFileSystemAbsolutePath(string path)
|
||||||
{
|
{
|
||||||
#if UNIX
|
#if UNIX
|
||||||
return path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal)
|
return path.StartsWith(StringLiterals.DefaultPathSeparator)
|
||||||
|| path.StartsWith(StringLiterals.AlternatePathSeparatorString, StringComparison.Ordinal);
|
|| path.StartsWith(StringLiterals.AlternatePathSeparator);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
@ -2898,7 +2898,7 @@ namespace System.Management.Automation
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal))
|
if (path.StartsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
formatString = "{0}:{1}";
|
formatString = "{0}:{1}";
|
||||||
}
|
}
|
||||||
|
@ -3088,8 +3088,8 @@ namespace System.Management.Automation
|
||||||
// Check if the path begins with "\" or "/" (UNC Path or Path in Unix).
|
// Check if the path begins with "\" or "/" (UNC Path or Path in Unix).
|
||||||
// Ignore if the path resolves to a drive path, this will happen when path is equal to "\" or "/".
|
// Ignore if the path resolves to a drive path, this will happen when path is equal to "\" or "/".
|
||||||
// Drive path still need formatting, so treat them as relative.
|
// Drive path still need formatting, so treat them as relative.
|
||||||
if (path.Length > 1 && (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal) ||
|
if (path.Length > 1 && (path.StartsWith(StringLiterals.DefaultPathSeparator) ||
|
||||||
path.StartsWith(StringLiterals.AlternatePathSeparatorString, StringComparison.Ordinal)))
|
path.StartsWith(StringLiterals.AlternatePathSeparator)))
|
||||||
{
|
{
|
||||||
treatAsRelative = false;
|
treatAsRelative = false;
|
||||||
}
|
}
|
||||||
|
@ -3109,7 +3109,7 @@ namespace System.Management.Automation
|
||||||
if (drive.VolumeSeparatedByColon)
|
if (drive.VolumeSeparatedByColon)
|
||||||
{
|
{
|
||||||
formatString = "{0}:" + StringLiterals.DefaultPathSeparator + "{1}";
|
formatString = "{0}:" + StringLiterals.DefaultPathSeparator + "{1}";
|
||||||
if (path.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal))
|
if (path.StartsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
formatString = "{0}:{1}";
|
formatString = "{0}:{1}";
|
||||||
}
|
}
|
||||||
|
|
|
@ -345,7 +345,7 @@ namespace System.Management.Automation.Provider
|
||||||
|
|
||||||
// Append the default path separator
|
// Append the default path separator
|
||||||
|
|
||||||
if (parent.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal))
|
if (parent.EndsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
result = parent;
|
result = parent;
|
||||||
}
|
}
|
||||||
|
@ -377,9 +377,9 @@ namespace System.Management.Automation.Provider
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder(parent, parent.Length + child.Length + 1);
|
StringBuilder builder = new StringBuilder(parent, parent.Length + child.Length + 1);
|
||||||
|
|
||||||
if (parent.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal))
|
if (parent.EndsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
if (child.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal))
|
if (child.StartsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
builder.Append(child, 1, child.Length - 1);
|
builder.Append(child, 1, child.Length - 1);
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ namespace System.Management.Automation.Provider
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (child.StartsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal))
|
if (child.StartsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
if (parent.Length == 0)
|
if (parent.Length == 0)
|
||||||
{
|
{
|
||||||
|
@ -598,7 +598,7 @@ namespace System.Management.Automation.Provider
|
||||||
string originalPath = path;
|
string originalPath = path;
|
||||||
Stack<string> tokenizedPathStack = null;
|
Stack<string> tokenizedPathStack = null;
|
||||||
|
|
||||||
if (path.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase))
|
if (path.EndsWith(StringLiterals.DefaultPathSeparator))
|
||||||
{
|
{
|
||||||
path = path.TrimEnd(StringLiterals.DefaultPathSeparator);
|
path = path.TrimEnd(StringLiterals.DefaultPathSeparator);
|
||||||
originalPathHadTrailingSlash = true;
|
originalPathHadTrailingSlash = true;
|
||||||
|
@ -608,7 +608,7 @@ namespace System.Management.Automation.Provider
|
||||||
// See if the base and the path are already the same. We resolve this to
|
// See if the base and the path are already the same. We resolve this to
|
||||||
// ..\Leaf, since resolving "." to "." doesn't offer much information.
|
// ..\Leaf, since resolving "." to "." doesn't offer much information.
|
||||||
if (String.Equals(normalizedPath, normalizedBasePath, StringComparison.OrdinalIgnoreCase) &&
|
if (String.Equals(normalizedPath, normalizedBasePath, StringComparison.OrdinalIgnoreCase) &&
|
||||||
(!originalPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
|
(!originalPath.EndsWith(StringLiterals.DefaultPathSeparator)))
|
||||||
{
|
{
|
||||||
string childName = GetChildName(path);
|
string childName = GetChildName(path);
|
||||||
result = MakePath("..", childName);
|
result = MakePath("..", childName);
|
||||||
|
@ -648,7 +648,7 @@ namespace System.Management.Automation.Provider
|
||||||
if (!String.IsNullOrEmpty(commonBase))
|
if (!String.IsNullOrEmpty(commonBase))
|
||||||
{
|
{
|
||||||
if (String.Equals(normalizedPath, commonBase, StringComparison.OrdinalIgnoreCase) &&
|
if (String.Equals(normalizedPath, commonBase, StringComparison.OrdinalIgnoreCase) &&
|
||||||
(!normalizedPath.EndsWith(StringLiterals.DefaultPathSeparatorString, StringComparison.OrdinalIgnoreCase)))
|
(!normalizedPath.EndsWith(StringLiterals.DefaultPathSeparator)))
|
||||||
{
|
{
|
||||||
string childName = GetChildName(path);
|
string childName = GetChildName(path);
|
||||||
result = MakePath("..", result);
|
result = MakePath("..", result);
|
||||||
|
|
Loading…
Reference in a new issue