Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PathInternal.cs
Go to the documentation of this file.
3
4namespace System.IO;
5
6internal static class PathInternal
7{
9 {
10 get
11 {
12 if (!IsCaseSensitive)
13 {
14 return StringComparison.OrdinalIgnoreCase;
15 }
16 return StringComparison.Ordinal;
17 }
18 }
19
20 internal static bool IsCaseSensitive
21 {
22 get
23 {
25 {
26 return !OperatingSystem.IsWatchOS();
27 }
28 return false;
29 }
30 }
31
32 internal static bool IsValidDriveChar(char value)
33 {
34 if (value < 'A' || value > 'Z')
35 {
36 if (value >= 'a')
37 {
38 return value <= 'z';
39 }
40 return false;
41 }
42 return true;
43 }
44
45 private static bool EndsWithPeriodOrSpace(string path)
46 {
47 if (string.IsNullOrEmpty(path))
48 {
49 return false;
50 }
51 char c = path[path.Length - 1];
52 if (c != ' ')
53 {
54 return c == '.';
55 }
56 return true;
57 }
58
59 [return: NotNullIfNotNull("path")]
60 internal static string EnsureExtendedPrefixIfNeeded(string path)
61 {
62 if (path != null && (path.Length >= 260 || EndsWithPeriodOrSpace(path)))
63 {
64 return EnsureExtendedPrefix(path);
65 }
66 return path;
67 }
68
69 internal static string EnsureExtendedPrefix(string path)
70 {
71 if (IsPartiallyQualified(path) || IsDevice(path))
72 {
73 return path;
74 }
75 if (path.StartsWith("\\\\", StringComparison.OrdinalIgnoreCase))
76 {
77 return path.Insert(2, "?\\UNC\\");
78 }
79 return "\\\\?\\" + path;
80 }
81
82 internal static bool IsDevice(string path)
83 {
84 if (!IsExtended(path))
85 {
86 if (path.Length >= 4 && IsDirectorySeparator(path[0]) && IsDirectorySeparator(path[1]) && (path[2] == '.' || path[2] == '?'))
87 {
88 return IsDirectorySeparator(path[3]);
89 }
90 return false;
91 }
92 return true;
93 }
94
95 internal static bool IsExtended(string path)
96 {
97 if (path.Length >= 4 && path[0] == '\\' && (path[1] == '\\' || path[1] == '?') && path[2] == '?')
98 {
99 return path[3] == '\\';
100 }
101 return false;
102 }
103
104 internal static bool IsPartiallyQualified(string path)
105 {
106 if (path.Length < 2)
107 {
108 return true;
109 }
110 if (IsDirectorySeparator(path[0]))
111 {
112 if (path[1] != '?')
113 {
114 return !IsDirectorySeparator(path[1]);
115 }
116 return false;
117 }
118 if (path.Length >= 3 && path[1] == Path.VolumeSeparatorChar && IsDirectorySeparator(path[2]))
119 {
120 return !IsValidDriveChar(path[0]);
121 }
122 return true;
123 }
124
125 [MethodImpl(MethodImplOptions.AggressiveInlining)]
126 internal static bool IsDirectorySeparator(char c)
127 {
129 {
131 }
132 return true;
133 }
134}
static bool IsValidDriveChar(char value)
static bool IsCaseSensitive
static bool IsDirectorySeparator(char c)
static bool EndsWithPeriodOrSpace(string path)
static string EnsureExtendedPrefix(string path)
static bool IsDevice(ReadOnlySpan< char > path)
static bool IsExtended(string path)
static bool IsExtended(ReadOnlySpan< char > path)
static bool IsPartiallyQualified(string path)
static bool IsDevice(string path)
static bool IsPartiallyQualified(ReadOnlySpan< char > path)
static string EnsureExtendedPrefixIfNeeded(string path)
static readonly char AltDirectorySeparatorChar
Definition Path.cs:73
static readonly char DirectorySeparatorChar
Definition Path.cs:71
static readonly char VolumeSeparatorChar
Definition Path.cs:75