Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corert.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnirudh Agnihotry <anirudhagnihotry098@gmail.com>2018-02-27 23:04:53 +0300
committerAnirudh Agnihotry <anirudhagnihotry098@gmail.com>2018-03-01 01:00:31 +0300
commit1039ab115369640766c900c35c02f97900864010 (patch)
treef145b4e4aac106170b7a0fa314082d72d9cbaa00
parentba5f5c6d540351ec435d0202a1da464f3b4297de (diff)
Tests For GetPathRoot and Enabling NormalizeDirectorySeparatorTests (#27494)
Corrects its Implementation too Signed-off-by: dotnet-bot-corefx-mirror <dotnet-bot@microsoft.com> Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
-rw-r--r--src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs b/src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs
index 433d6b6a3..f931380c7 100644
--- a/src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs
+++ b/src/System.Private.CoreLib/shared/System/IO/PathInternal.Windows.cs
@@ -190,6 +190,7 @@ namespace System.IO
int i = 0;
int volumeSeparatorLength = 2; // Length to the colon "C:"
int uncRootLength = 2; // Length to the start of the server name "\\"
+ int devicePrefixLength = PathInternal.ExtendedPathPrefix.Length;
bool deviceSyntax = IsDevice(path);
bool deviceUnc = deviceSyntax && IsDeviceUNC(path);
@@ -201,10 +202,10 @@ namespace System.IO
// "\\" -> "\\?\UNC\"
uncRootLength = UncExtendedPathPrefix.Length;
}
- else
+ else if (devicePrefixLength + 1 < pathLength && path[devicePrefixLength + 1] == VolumeSeparatorChar && IsValidDriveChar(path[devicePrefixLength]))
{
// "C:" -> "\\?\C:"
- volumeSeparatorLength += ExtendedPathPrefix.Length;
+ volumeSeparatorLength += devicePrefixLength;
}
}
@@ -233,7 +234,18 @@ namespace System.IO
if (pathLength >= volumeSeparatorLength + 1 && IsDirectorySeparator(path[volumeSeparatorLength]))
i++;
}
- return i;
+ else if (deviceSyntax && ((devicePrefixLength + 1 >= pathLength) || !(path[devicePrefixLength + 1] == VolumeSeparatorChar)))
+ {
+ i = devicePrefixLength;
+ int n = 1; // Maximum separators to skip
+ while (i < pathLength && (!IsDirectorySeparator(path[i]) || --n > 0))
+ i++;
+
+ if (i == devicePrefixLength)
+ i--;
+ }
+
+ return (i < pathLength && IsDirectorySeparator(path[i])) ? i + 1 : i;
}
private static bool StartsWithOrdinal(ReadOnlySpan<char> source, string value)