forked from CFPAOrg/Minecraft-Mod-Language-Package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtils.cs
51 lines (46 loc) · 1.46 KB
/
Utils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Language.Core
{
public static class Utils
{
private static List<string> ReadBlackKey()
{
var res = new List<string>();
foreach (string str in File.ReadAllLines($"{Directory.GetCurrentDirectory()}/config/blackkey.txt", Encoding.UTF8))
{
res.Add(str);
}
return res;
}
public static void DeleteBlackKeys(string path)
{
var bl = ReadBlackKey();
var keyReg = new Regex(".+(?==)");
var nameReg = new Regex("(?<==).+");
var findEqual = new Regex("=+");
var commentReg = new Regex("#+");
var ls = new List<string>();
foreach (string str in File.ReadAllLines(path))
{
if (findEqual.IsMatch(str))
{
if (keyReg.IsMatch(str))
{
if (bl.Contains(keyReg.Match(str).ToString()))
{
continue;
}
ls.Add(str);
}
else ls.Add(str);
}
else ls.Add(str);
}
File.WriteAllLines(path, ls);
}
}
}