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

◆ RemoveRelativeSegments() [1/2]

static bool System.IO.PathInternal.RemoveRelativeSegments ( ReadOnlySpan< char > path,
int rootLength,
ref ValueStringBuilder sb )
inlinestaticpackage

Definition at line 145 of file PathInternal.cs.

146 {
147 bool flag = false;
148 int num = rootLength;
149 if (IsDirectorySeparator(path[num - 1]))
150 {
151 num--;
152 }
153 if (num > 0)
154 {
155 sb.Append(path.Slice(0, num));
156 }
157 for (int i = num; i < path.Length; i++)
158 {
159 char c = path[i];
160 if (IsDirectorySeparator(c) && i + 1 < path.Length)
161 {
162 if (IsDirectorySeparator(path[i + 1]))
163 {
164 continue;
165 }
166 if ((i + 2 == path.Length || IsDirectorySeparator(path[i + 2])) && path[i + 1] == '.')
167 {
168 i++;
169 continue;
170 }
171 if (i + 2 < path.Length && (i + 3 == path.Length || IsDirectorySeparator(path[i + 3])) && path[i + 1] == '.' && path[i + 2] == '.')
172 {
173 int num2;
174 for (num2 = sb.Length - 1; num2 >= num; num2--)
175 {
176 if (IsDirectorySeparator(sb[num2]))
177 {
178 sb.Length = ((i + 3 >= path.Length && num2 == num) ? (num2 + 1) : num2);
179 break;
180 }
181 }
182 if (num2 < num)
183 {
184 sb.Length = num;
185 }
186 i += 2;
187 continue;
188 }
189 }
190 if (c != '\\' && c == '/')
191 {
192 c = '\\';
193 flag = true;
194 }
195 sb.Append(c);
196 }
197 if (!flag && sb.Length == path.Length)
198 {
199 return false;
200 }
201 if (num != rootLength && sb.Length < rootLength)
202 {
203 sb.Append(path[rootLength - 1]);
204 }
205 return true;
206 }
static bool IsDirectorySeparator(char c)
ReadOnlySpan< T > Slice(int start)

References System.IO.PathInternal.IsDirectorySeparator(), System.ReadOnlySpan< T >.Length, and System.ReadOnlySpan< T >.Slice().