Bug in GetFullPath(basePath, Path) (#16598)
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>
Tue, 27 Feb 2018 23:56:23 +0000 (15:56 -0800)
committerJeremy Kuhne <jeremy.kuhne@microsoft.com>
Tue, 27 Feb 2018 23:56:23 +0000 (15:56 -0800)
* GetFullPath and GetRootLength Corrected

* Removed getpathroot

* using span

* "\\" changed to @"\"

src/mscorlib/shared/System/IO/Path.Windows.cs

index 6a8745d..c92211f 100644 (file)
@@ -98,8 +98,8 @@ namespace System.IO
                 {
                     // 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, "\\");
+                    // "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, "\\");
                 }
             }
             else