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

◆ CleanPath()

static string ReLogic.Content.AssetPathHelper.CleanPath ( string path)
inlinestatic

Definition at line 8 of file AssetPathHelper.cs.

9 {
10 path = path.Replace("/", "\\", StringComparison.Ordinal);
11 path = path.Replace("\\.\\", "\\", StringComparison.Ordinal);
12 while (path.StartsWith(".\\", StringComparison.Ordinal))
13 {
14 path = path.Substring(".\\".Length);
15 }
16 while (path.EndsWith("\\.", StringComparison.Ordinal))
17 {
18 path = ((path.Length <= "\\.".Length) ? "\\" : path.Substring(0, path.Length - "\\.".Length));
19 }
20 int num;
21 for (num = 1; num < path.Length; num = CollapseParentDirectory(ref path, num, "\\..\\".Length))
22 {
23 num = path.IndexOf("\\..\\", num, StringComparison.Ordinal);
24 if (num < 0)
25 {
26 break;
27 }
28 }
29 if (path.EndsWith("\\..", StringComparison.Ordinal))
30 {
31 int num2 = path.Length - "\\..".Length;
32 if (num2 > 0)
33 {
34 CollapseParentDirectory(ref path, num2, "\\..".Length);
35 }
36 }
37 if (path == ".")
38 {
39 path = string.Empty;
40 }
41 if (Path.DirectorySeparatorChar != '\\')
42 {
43 path = path.Replace("\\", Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal);
44 }
45 return path;
46 }
static int CollapseParentDirectory(ref string path, int position, int removeLength)
static readonly char DirectorySeparatorChar
Definition Path.cs:71

References ReLogic.Content.AssetPathHelper.CollapseParentDirectory(), and System.IO.Path.DirectorySeparatorChar.

Referenced by ReLogic.Content.Sources.XnaDirectContentSource.XnaDirectContentSource(), ReLogic.Content.Sources.ZipContentSource.BuildEntryList(), ReLogic.Content.Sources.FileSystemContentSource.BuildNameToAbsolutePathDictionary(), ReLogic.Content.Sources.ContentSource.GetExtension(), ReLogic.Content.AssetRepository.Request< T >(), and ReLogic.Content.Sources.ContentSource.SetAssetNames().