ValidateFolderName.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Runtime.CompilerServices;
  5. using Microsoft.VisualBasic.CompilerServices;
  6. namespace PCL
  7. {
  8. // Token: 0x0200014A RID: 330
  9. public class ValidateFolderName : Validate
  10. {
  11. // Token: 0x17000213 RID: 531
  12. // (get) Token: 0x06000D93 RID: 3475 RVA: 0x00008B20 File Offset: 0x00006D20
  13. // (set) Token: 0x06000D94 RID: 3476 RVA: 0x00008B28 File Offset: 0x00006D28
  14. public string Path { get; set; }
  15. // Token: 0x06000D95 RID: 3477 RVA: 0x00008B31 File Offset: 0x00006D31
  16. [CompilerGenerated]
  17. public bool SelectClient()
  18. {
  19. return this.m_ResolverTests;
  20. }
  21. // Token: 0x06000D96 RID: 3478 RVA: 0x00008B39 File Offset: 0x00006D39
  22. [CompilerGenerated]
  23. public void ReadClient(bool AutoPropertyValue)
  24. {
  25. this.m_ResolverTests = AutoPropertyValue;
  26. }
  27. // Token: 0x06000D97 RID: 3479 RVA: 0x00008B42 File Offset: 0x00006D42
  28. [CompilerGenerated]
  29. public bool ResolveClient()
  30. {
  31. return this._StatusTests;
  32. }
  33. // Token: 0x06000D98 RID: 3480 RVA: 0x00008B4A File Offset: 0x00006D4A
  34. [CompilerGenerated]
  35. public void ReflectClient(bool AutoPropertyValue)
  36. {
  37. this._StatusTests = AutoPropertyValue;
  38. }
  39. // Token: 0x06000D99 RID: 3481 RVA: 0x00008B53 File Offset: 0x00006D53
  40. public ValidateFolderName()
  41. {
  42. this.ReadClient(true);
  43. this.ReflectClient(true);
  44. }
  45. // Token: 0x06000D9A RID: 3482 RVA: 0x0005BC1C File Offset: 0x00059E1C
  46. public ValidateFolderName(string Path, bool UseMinecraftCharCheck = true, bool IgnoreCase = true)
  47. {
  48. this.ReadClient(true);
  49. this.ReflectClient(true);
  50. int num2;
  51. int num4;
  52. object obj;
  53. try
  54. {
  55. IL_15:
  56. int num = 1;
  57. this.Path = Path;
  58. IL_1E:
  59. num = 2;
  60. this.ReflectClient(IgnoreCase);
  61. IL_27:
  62. num = 3;
  63. this.ReadClient(UseMinecraftCharCheck);
  64. IL_30:
  65. ProjectData.ClearProjectError();
  66. num2 = 1;
  67. IL_37:
  68. num = 5;
  69. this.m_RoleTests = new DirectoryInfo(Path).EnumerateDirectories();
  70. IL_4A:
  71. goto IL_B1;
  72. IL_4C:
  73. int num3 = num4 + 1;
  74. num4 = 0;
  75. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num3);
  76. IL_72:
  77. goto IL_A6;
  78. IL_74:
  79. num4 = num;
  80. @switch(ICSharpCode.Decompiler.ILAst.ILLabel[], num2);
  81. IL_84:;
  82. }
  83. catch when (endfilter(obj is Exception & num2 != 0 & num4 == 0))
  84. {
  85. Exception ex = (Exception)obj2;
  86. goto IL_74;
  87. }
  88. IL_A6:
  89. throw ProjectData.CreateProjectError(-2146828237);
  90. IL_B1:
  91. if (num4 != 0)
  92. {
  93. ProjectData.ClearProjectError();
  94. }
  95. }
  96. // Token: 0x06000D9B RID: 3483 RVA: 0x0005BCF4 File Offset: 0x00059EF4
  97. public override string Validate(string Str)
  98. {
  99. string result;
  100. try
  101. {
  102. string text = new ValidateNullOrWhiteSpace().Validate(Str);
  103. if (Operators.CompareString(text, "", false) != 0)
  104. {
  105. result = text;
  106. }
  107. else if (Str.StartsWithF(" ", false))
  108. {
  109. result = "文件夹名不能以空格开头!";
  110. }
  111. else if (Str.EndsWithF(" ", false))
  112. {
  113. result = "文件夹名不能以空格结尾!";
  114. }
  115. else
  116. {
  117. text = new ValidateLength(1, 100).Validate(Str);
  118. if (Operators.CompareString(text, "", false) != 0)
  119. {
  120. result = text;
  121. }
  122. else if (Str.EndsWithF(".", false))
  123. {
  124. result = "文件夹名不能以小数点结尾!";
  125. }
  126. else
  127. {
  128. string text2 = new ValidateExcept(new string(System.IO.Path.GetInvalidFileNameChars()) + (this.SelectClient() ? "!;" : ""), "文件夹名不可包含 % 字符!").Validate(Str);
  129. if (Operators.CompareString(text2, "", false) != 0)
  130. {
  131. result = text2;
  132. }
  133. else
  134. {
  135. string text3 = new ValidateExceptSame(new string[]
  136. {
  137. "CON",
  138. "PRN",
  139. "AUX",
  140. "CLOCK$",
  141. "NUL",
  142. "COM0",
  143. "COM1",
  144. "COM2",
  145. "COM3",
  146. "COM4",
  147. "COM5",
  148. "COM6",
  149. "COM7",
  150. "COM8",
  151. "COM9",
  152. "LPT0",
  153. "LPT1",
  154. "LPT2",
  155. "LPT3",
  156. "LPT4",
  157. "LPT5",
  158. "LPT6",
  159. "LPT7",
  160. "LPT8",
  161. "LPT9"
  162. }, "文件夹名不可为 %!", true).Validate(Str);
  163. if (Operators.CompareString(text3, "", false) != 0)
  164. {
  165. result = text3;
  166. }
  167. else if (ModBase.RegexCheck(Str, ".{2,}~\\d", 0))
  168. {
  169. result = "文件夹名不能包含这一特殊格式!";
  170. }
  171. else
  172. {
  173. List<string> list = new List<string>();
  174. if (this.m_RoleTests != null)
  175. {
  176. try
  177. {
  178. foreach (DirectoryInfo directoryInfo in this.m_RoleTests)
  179. {
  180. list.Add(directoryInfo.Name);
  181. }
  182. }
  183. finally
  184. {
  185. IEnumerator<DirectoryInfo> enumerator;
  186. if (enumerator != null)
  187. {
  188. enumerator.Dispose();
  189. }
  190. }
  191. }
  192. string text4 = new ValidateExceptSame(list, "不可与现有文件夹重名!", this.ResolveClient()).Validate(Str);
  193. if (Operators.CompareString(text4, "", false) != 0)
  194. {
  195. result = text4;
  196. }
  197. else
  198. {
  199. result = "";
  200. }
  201. }
  202. }
  203. }
  204. }
  205. }
  206. catch (Exception ex)
  207. {
  208. ModBase.Log(ex, "检查文件夹名出错", ModBase.LogLevel.Debug, "出现错误");
  209. result = "错误:" + ex.Message;
  210. }
  211. return result;
  212. }
  213. // Token: 0x04000710 RID: 1808
  214. [CompilerGenerated]
  215. private string m_ServerTests;
  216. // Token: 0x04000711 RID: 1809
  217. [CompilerGenerated]
  218. private bool m_ResolverTests;
  219. // Token: 0x04000712 RID: 1810
  220. [CompilerGenerated]
  221. private bool _StatusTests;
  222. // Token: 0x04000713 RID: 1811
  223. private readonly IEnumerable<DirectoryInfo> m_RoleTests;
  224. }
  225. }