Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PasteArguments.cs
Go to the documentation of this file.
2using System.Text;
3
4namespace System;
5
6internal static class PasteArguments
7{
9 {
10 if (stringBuilder.Length != 0)
11 {
12 stringBuilder.Append(' ');
13 }
15 {
16 stringBuilder.Append(argument);
17 return;
18 }
19 stringBuilder.Append('"');
20 int num = 0;
21 while (num < argument.Length)
22 {
23 char c = argument[num++];
24 switch (c)
25 {
26 case '\\':
27 {
28 int num2 = 1;
29 while (num < argument.Length && argument[num] == '\\')
30 {
31 num++;
32 num2++;
33 }
34 if (num == argument.Length)
35 {
36 stringBuilder.Append('\\', num2 * 2);
37 }
38 else if (argument[num] == '"')
39 {
40 stringBuilder.Append('\\', num2 * 2 + 1);
41 stringBuilder.Append('"');
42 num++;
43 }
44 else
45 {
46 stringBuilder.Append('\\', num2);
47 }
48 break;
49 }
50 case '"':
51 stringBuilder.Append('\\');
52 stringBuilder.Append('"');
53 break;
54 default:
55 stringBuilder.Append(c);
56 break;
57 }
58 }
59 stringBuilder.Append('"');
60 }
61
62 private static bool ContainsNoWhitespaceOrQuotes(string s)
63 {
64 foreach (char c in s)
65 {
66 if (char.IsWhiteSpace(c) || c == '"')
67 {
68 return false;
69 }
70 }
71 return true;
72 }
73
75 {
78 foreach (string argument in arguments)
79 {
81 {
83 bool flag = false;
84 string text = argument;
85 foreach (char c in text)
86 {
87 if (c == '"')
88 {
90 }
91 if (char.IsWhiteSpace(c))
92 {
93 flag = true;
94 }
95 }
96 if (argument.Length == 0 || flag)
97 {
98 stringBuilder.Append('"');
99 stringBuilder.Append(argument);
100 stringBuilder.Append('"');
101 }
102 else
103 {
104 stringBuilder.Append(argument);
105 }
106 }
107 else
108 {
110 }
111 }
112 return stringBuilder.ToString();
113 }
114}
static void AppendArgument(ref System.Text.ValueStringBuilder stringBuilder, string argument)
static string Paste(IEnumerable< string > arguments, bool pasteFirstArgumentUsingArgV0Rules)
static bool ContainsNoWhitespaceOrQuotes(string s)
static void AppendArgument(ref ValueStringBuilder stringBuilder, string argument)
static string Argv_IncludeDoubleQuote
Definition SR.cs:2186
Definition SR.cs:7