-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Conversation
@@ -99,7 +99,7 @@ public static string GetFullPath(string path, string basePath) | |||
// No matching root, root to specified drive | |||
// "D:Foo" and "C:\Bar" => "D:Foo" | |||
// "D:\Foo" and "\\?\C:\Bar" => "\\?\D:\Foo" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be "D:Foo" and "\\?\C:\Bar" => "\\?\D:\Foo"
@@ -99,7 +99,7 @@ public static string GetFullPath(string path, string basePath) | |||
// No matching root, root to specified drive | |||
// "D:Foo" and "C:\Bar" => "D:Foo" | |||
// "D:\Foo" and "\\?\C:\Bar" => "\\?\D:\Foo" | |||
combinedPath = path.Insert(2, "\\"); | |||
combinedPath = PathInternal.IsDevice(basePath) ? basePath.Substring(0,4) + path.Insert(2, "\\") : path.Insert(2, "\\"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could save some allocations by using CombineNoChecksInternal(). If you take a span and slice it on the original string you can end up with "C:" and "foo". Then you can slice basepath as well if you need the third one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that your other CombineNoChecks usages should probably be CombineNoChecksInternal. I don't think you want the rooting behavior.
// "D:\Foo" and "\\?\C:\Bar" => "\\?\D:\Foo" | ||
combinedPath = path.Insert(2, "\\"); | ||
// "D:Foo" and "\\?\C:\Bar" => "\\?\D:\Foo" | ||
combinedPath = PathInternal.IsDevice(basePath) ? CombineNoChecksInternal(basePath.AsSpan().Slice(0, 4), path.AsSpan().Slice(0, 2), "\\", path.AsSpan().Slice(2)) : path.Insert(2, "\\"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit- it would be easier to read if "\\"
was changed to @"\"
* GetFullPath and GetRootLength Corrected * Removed getpathroot * using span * "\\" changed to @"\" Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* GetFullPath and GetRootLength Corrected * Removed getpathroot * using span * "\\" changed to @"\" Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* GetFullPath and GetRootLength Corrected * Removed getpathroot * using span * "\\" changed to @"\"
* GetFullPath and GetRootLength Corrected * Removed getpathroot * using span * "\\" changed to @"\" Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
* GetFullPath and GetRootLength Corrected * Removed getpathroot * using span * "\\" changed to @"\" Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com>
* GetFullPath and GetRootLength Corrected * Removed getpathroot * using span * "\\" changed to @"\" Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
This change corrects the Case when base path is a device path and path is a specific drive relative path