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

◆ NormalizeInputs()

static bool System.IO.Enumeration.FileSystemEnumerableFactory.NormalizeInputs ( ref string directory,
ref string expression,
MatchType matchType )
inlinestaticpackage

Definition at line 9 of file FileSystemEnumerableFactory.cs.

10 {
11 if (Path.IsPathRooted(expression))
12 {
13 throw new ArgumentException(SR.Arg_Path2IsRooted, "expression");
14 }
15 if (expression.Contains('\0'))
16 {
17 throw new ArgumentException(SR.Argument_InvalidPathChars, expression);
18 }
19 if (directory.Contains('\0'))
20 {
21 throw new ArgumentException(SR.Argument_InvalidPathChars, directory);
22 }
23 ReadOnlySpan<char> directoryName = Path.GetDirectoryName(expression.AsSpan());
24 bool result = true;
25 if (directoryName.Length != 0)
26 {
27 directory = Path.Join(directory.AsSpan(), directoryName);
28 expression = expression.Substring(directoryName.Length + 1);
29 result = false;
30 }
31 switch (matchType)
32 {
33 case MatchType.Win32:
34 if (expression == "*")
35 {
36 break;
37 }
38 if (string.IsNullOrEmpty(expression) || expression == "." || expression == "*.*")
39 {
40 expression = "*";
41 break;
42 }
43 if (Path.DirectorySeparatorChar != '\\' && expression.IndexOfAny(s_unixEscapeChars) != -1)
44 {
45 expression = expression.Replace("\\", "\\\\");
46 expression = expression.Replace("\"", "\\\"");
47 expression = expression.Replace(">", "\\>");
48 expression = expression.Replace("<", "\\<");
49 }
50 expression = FileSystemName.TranslateWin32Expression(expression);
51 break;
52 default:
53 throw new ArgumentOutOfRangeException("matchType");
54 case MatchType.Simple:
55 break;
56 }
57 return result;
58 }
bool ICollection< KeyValuePair< TKey, TValue > >. Contains(KeyValuePair< TKey, TValue > keyValuePair)

References System.SR.Arg_Path2IsRooted, System.SR.Argument_InvalidPathChars, System.Collections.Generic.Dictionary< TKey, TValue >.Contains(), System.IO.Path.DirectorySeparatorChar, System.IO.Path.GetDirectoryName(), System.IO.Path.IsPathRooted(), System.IO.Path.Join(), System.IO.Enumeration.FileSystemEnumerableFactory.s_unixEscapeChars, and System.IO.Enumeration.FileSystemName.TranslateWin32Expression().

Referenced by System.IO.DirectoryInfo.InternalEnumerateInfos(), and System.IO.Directory.InternalEnumeratePaths().