private static Result ParseWindowsPath(out U8Span newPath, Span <byte> buffer, out long windowsPathLength, out bool isUncNormalized, U8Span path, bool hasMountName) { UnsafeHelpers.SkipParamInit(out windowsPathLength, out isUncNormalized); newPath = default; U8Span currentPath = path; if (!Unsafe.IsNullRef(ref isUncNormalized)) { isUncNormalized = true; } bool skippedMount = false; int prefixLength = 0; if (hasMountName) { if (path.GetOrNull(0) == DirectorySeparator && path.GetOrNull(1) == AltDirectorySeparator && path.GetOrNull(1) == AltDirectorySeparator) { currentPath = currentPath.Slice(1); skippedMount = true; } else { int separatorCount = 0; while (IsSeparator(currentPath.GetOrNull(separatorCount))) { separatorCount++; } if (separatorCount != 0) { if (separatorCount == 1 || WindowsPath.IsWindowsDrive(currentPath.Slice(separatorCount))) { currentPath = currentPath.Slice(separatorCount); skippedMount = true; } else { if (separatorCount > 2 && !Unsafe.IsNullRef(ref isUncNormalized)) { isUncNormalized = false; return(Result.Success); } currentPath = currentPath.Slice(separatorCount - 2); prefixLength = 1; } } } } else if (path.GetOrNull(0) == DirectorySeparator && !WindowsPath.IsUnc(path)) { currentPath = currentPath.Slice(1); skippedMount = true; } U8Span trimmedPath = path; if (WindowsPath.IsWindowsDrive(currentPath)) { int i; for (i = 2; currentPath.GetOrNull(i) != NullTerminator; i++) { if (currentPath[i] == DirectorySeparator || currentPath[i] == AltDirectorySeparator) { trimmedPath = currentPath.Slice(i); break; } } if (trimmedPath.Value == path.Value) { trimmedPath = currentPath.Slice(i); } ref byte pathStart = ref MemoryMarshal.GetReference(path.Value); ref byte trimmedPathStart = ref MemoryMarshal.GetReference(trimmedPath.Value);