Skip to content

Commit

Permalink
Update Path.Windows.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
steveberdy authored Jul 8, 2021
1 parent d9f1ade commit 16270cd
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions src/libraries/System.Private.CoreLib/src/System/IO/Path.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,8 @@ public static string GetFullPath(string path)
// unpredictable results.
if (path.Contains('\0'))
throw new ArgumentException(SR.Argument_InvalidPathChars, nameof(path));

if (PathInternal.IsExtended(path.AsSpan()))
{
// \\?\ paths are considered normalized by definition. Windows doesn't normalize \\?\
// paths and neither should we. Even if we wanted to GetFullPathName does not work
// properly with device paths. If one wants to pass a \\?\ path through normalization
// one can chop off the prefix, pass it to GetFullPath and add it again.
return path;
}

return PathHelper.Normalize(path);

return GetFullQualifiedPath(path);
}

public static string GetFullPath(string path, string basePath)
Expand All @@ -77,7 +68,7 @@ public static string GetFullPath(string path, string basePath)
throw new ArgumentException(SR.Argument_InvalidPathChars);

if (IsPathFullyQualified(path))
return GetFullPath(path);
return GetFullQualifiedPath(path);

if (PathInternal.IsEffectivelyEmpty(path.AsSpan()))
return basePath;
Expand Down Expand Up @@ -129,7 +120,21 @@ public static string GetFullPath(string path, string basePath)

return PathInternal.IsDevice(combinedPath.AsSpan())
? PathInternal.RemoveRelativeSegments(combinedPath, PathInternal.GetRootLength(combinedPath.AsSpan()))
: GetFullPath(combinedPath);
: GetFullQualifiedPath(combinedPath);
}

private static string GetFullQualifiedPath(string path)
{
if (PathInternal.IsExtended(path.AsSpan()))
{
// \\?\ paths are considered normalized by definition. Windows doesn't normalize \\?\
// paths and neither should we. Even if we wanted to GetFullPathName does not work
// properly with device paths. If one wants to pass a \\?\ path through normalization
// one can chop off the prefix, pass it to GetFullPath and add it again.
return path;
}

return PathHelper.Normalize(path);
}

public static string GetTempPath()
Expand Down

0 comments on commit 16270cd

Please sign in to comment.