Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ GetRootLength() [2/2]

static int System.IO.PathInternal.GetRootLength ( ReadOnlySpan< char > path)
inlinestaticpackage

Definition at line 335 of file PathInternal.cs.

336 {
337 int length = path.Length;
338 int i = 0;
339 bool flag = IsDevice(path);
340 bool flag2 = flag && IsDeviceUNC(path);
341 if ((!flag || flag2) && length > 0 && IsDirectorySeparator(path[0]))
342 {
343 if (flag2 || (length > 1 && IsDirectorySeparator(path[1])))
344 {
345 i = (flag2 ? 8 : 2);
346 int num = 2;
347 for (; i < length; i++)
348 {
349 if (IsDirectorySeparator(path[i]) && --num <= 0)
350 {
351 break;
352 }
353 }
354 }
355 else
356 {
357 i = 1;
358 }
359 }
360 else if (flag)
361 {
362 for (i = 4; i < length && !IsDirectorySeparator(path[i]); i++)
363 {
364 }
365 if (i < length && i > 4 && IsDirectorySeparator(path[i]))
366 {
367 i++;
368 }
369 }
370 else if (length >= 2 && path[1] == ':' && IsValidDriveChar(path[0]))
371 {
372 i = 2;
373 if (length > 2 && IsDirectorySeparator(path[2]))
374 {
375 i++;
376 }
377 }
378 return i;
379 }
static bool IsValidDriveChar(char value)
static bool IsDirectorySeparator(char c)
static bool IsDevice(ReadOnlySpan< char > path)
static bool IsDeviceUNC(ReadOnlySpan< char > path)

References System.IO.PathInternal.IsDevice(), System.IO.PathInternal.IsDeviceUNC(), System.IO.PathInternal.IsDirectorySeparator(), System.IO.PathInternal.IsValidDriveChar(), System.length, and System.ReadOnlySpan< T >.Length.