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

◆ TryJoin() [2/2]

static bool System.IO.Path.TryJoin ( ReadOnlySpan< char > path1,
ReadOnlySpan< char > path2,
Span< char > destination,
out int charsWritten )
inlinestatic

Definition at line 492 of file Path.cs.

493 {
494 charsWritten = 0;
495 if (path1.Length == 0 && path2.Length == 0)
496 {
497 return true;
498 }
499 if (path1.Length == 0 || path2.Length == 0)
500 {
501 ref ReadOnlySpan<char> reference = ref path1.Length == 0 ? ref path2 : ref path1;
502 if (destination.Length < reference.Length)
503 {
504 return false;
505 }
506 reference.CopyTo(destination);
507 charsWritten = reference.Length;
508 return true;
509 }
510 bool flag = !EndsInDirectorySeparator(path1) && !PathInternal.StartsWithDirectorySeparator(path2);
511 int num = path1.Length + path2.Length + (flag ? 1 : 0);
512 if (destination.Length < num)
513 {
514 return false;
515 }
516 path1.CopyTo(destination);
517 if (flag)
518 {
519 destination[path1.Length] = DirectorySeparatorChar;
520 }
521 path2.CopyTo(destination.Slice(path1.Length + (flag ? 1 : 0)));
522 charsWritten = num;
523 return true;
524 }
static readonly char DirectorySeparatorChar
Definition Path.cs:71
static bool EndsInDirectorySeparator(ReadOnlySpan< char > path)
Definition Path.cs:848
void CopyTo(Span< T > destination)

References System.ReadOnlySpan< T >.CopyTo(), System.destination, System.IO.Path.DirectorySeparatorChar, System.IO.Path.EndsInDirectorySeparator(), System.ReadOnlySpan< T >.Length, and System.IO.PathInternal.StartsWithDirectorySeparator().

Referenced by System.IO.Path.TryJoin().