See this:
|
/// <summary> |
|
/// Determines whether the specified source contains a drive letter. |
|
/// </summary> |
|
/// <param name="source">A read-only span of characters to be checked.</param> |
|
/// <returns> |
|
/// <c>true</c> if the source contains a drive letter (e.g., 'C:'); otherwise, <c>false</c>. |
|
/// </returns> |
|
private static bool SourceContainsDriveLetter(ReadOnlySpan<char> source) |
|
{ |
|
if (source.Length < 2) |
|
{ |
|
return false; |
|
} |
|
|
|
return source[1] == VolumeSeparatorChar && (uint)((source[0] | 0x20) - 'a') <= 'z' - 'a'; |
|
} |
It seems this will break for paths like C:/ or /: on Unix.
Guard this per OS. Best of all, make the OS or bool checkDriveLetter a parameter, to keep the function behavior independent of OS.
See this:
TruePath/TruePath/PathStrings.cs
Lines 176 to 191 in f410e9a
It seems this will break for paths like
C:/or/:on Unix.Guard this per OS. Best of all, make the OS or
bool checkDriveLettera parameter, to keep the function behavior independent of OS.