7internal static class PathInternal
77 if (
string.IsNullOrEmpty(first) ||
string.IsNullOrEmpty(second))
82 fixed (
char* ptr2 = first)
88 intPtr = (ptr =
null);
91 char* ptr5 = ptr3 + first.Length;
92 char* ptr6 = ptr4 + second.Length;
93 while (ptr3 != ptr5 && ptr4 != ptr6 && (*ptr3 == *ptr4 || (ignoreCase &&
char.ToUpperInvariant(*ptr3) ==
char.ToUpperInvariant(*ptr4))))
102 fixed (
char* ptr7 = &second.GetPinnableReference())
105 intPtr = (ptr = ptr7);
108 char* ptr5 = ptr3 + first.Length;
109 char* ptr6 = ptr4 + second.Length;
110 while (ptr3 != ptr5 && ptr4 != ptr6 && (*ptr3 == *ptr4 || (ignoreCase &&
char.ToUpperInvariant(*ptr3) ==
char.ToUpperInvariant(*ptr4))))
126 if (rootLength == rootLength2)
128 return string.Compare(first, 0, second, 0, rootLength,
comparisonType) == 0;
135 Span<char> initialBuffer = stackalloc
char[260];
148 int num = rootLength;
155 sb.Append(path.
Slice(0, num));
157 for (
int i = num; i < path.
Length; i++)
174 for (num2 = sb.Length - 1; num2 >= num; num2--)
178 sb.Length = ((i + 3 >= path.Length && num2 == num) ? (num2 + 1) : num2);
190 if (c !=
'\\' && c ==
'/')
197 if (!flag && sb.Length == path.
Length)
201 if (num != rootLength && sb.Length < rootLength)
203 sb.Append(path[rootLength - 1]);
208 [
return: NotNullIfNotNull(
"path")]
215 return path.Substring(0, path.Length - 1);
220 if (!
string.IsNullOrEmpty(path))
269 if (
string.IsNullOrEmpty(path))
273 char c = path[path.Length - 1];
281 [
return: NotNullIfNotNull(
"path")]
299 return path.Insert(2,
"?\\UNC\\");
301 return "\\\\?\\" + path;
321 return path[6] ==
'C';
328 if (path.
Length >= 4 && path[0] ==
'\\' && (path[1] ==
'\\' || path[1] ==
'?') && path[2] ==
'?')
330 return path[3] ==
'\\';
412 [
return: NotNullIfNotNull(
"path")]
415 if (
string.IsNullOrEmpty(path))
420 for (
int i = 0; i < path.Length; i++)
433 Span<char> initialBuffer = stackalloc
char[260];
439 valueStringBuilder.
Append(
'\\');
441 for (
int j = num; j < path.Length; j++)
452 valueStringBuilder.
Append(c);
454 return valueStringBuilder.
ToString();
464 for (
int i = 0; i < readOnlySpan.
Length; i++)
466 char c = readOnlySpan[i];
static bool EndsInDirectorySeparator(string path)
static string RemoveRelativeSegments(string path, int rootLength)
static bool IsValidDriveChar(char value)
static int GetRootLength(ReadOnlySpan< char > path)
static bool EndsInDirectorySeparator(ReadOnlySpan< char > path)
static string TrimEndingDirectorySeparator(string path)
static unsafe int EqualStartingCharacterCount(string first, string second, bool ignoreCase)
static bool IsCaseSensitive
static string GetLinkTargetFullPath(string path, string pathToTarget)
static bool IsDirectorySeparator(char c)
static bool EndsWithPeriodOrSpace(string path)
static bool StartsWithDirectorySeparator(ReadOnlySpan< char > path)
static string EnsureExtendedPrefix(string path)
static bool IsDevice(ReadOnlySpan< char > path)
static ReadOnlySpan< char > TrimEndingDirectorySeparator(ReadOnlySpan< char > path)
static bool IsExtended(ReadOnlySpan< char > path)
static bool RemoveRelativeSegments(ReadOnlySpan< char > path, int rootLength, ref ValueStringBuilder sb)
static bool AreRootsEqual(string first, string second, StringComparison comparisonType)
static string NormalizeDirectorySeparators(string path)
static bool IsDeviceUNC(ReadOnlySpan< char > path)
static bool IsPartiallyQualified(ReadOnlySpan< char > path)
static bool IsRoot(ReadOnlySpan< char > path)
static string EnsureExtendedPrefixIfNeeded(string path)
static bool IsEffectivelyEmpty(ReadOnlySpan< char > path)
static int GetCommonPathLength(string first, string second, bool ignoreCase)
static string EnsureTrailingSeparator(string path)
static string Join(ReadOnlySpan< char > path1, ReadOnlySpan< char > path2)
static ? string GetDirectoryName(string? path)
ReadOnlySpan< T > Slice(int start)
override string ToString()