forked from fredriksa/WoWLauncher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPatchDeleter.cs
45 lines (37 loc) · 1.32 KB
/
PatchDeleter.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.RegularExpressions;
namespace Launcher
{
class PatchDeleter
{
public static void delete(Server server)
{
string dataDirectory = Path.Combine(server.clientDirectory + "\\Data\\");
if (!Directory.Exists(dataDirectory)) return;
string[] files = Directory.GetFiles(dataDirectory);
string[] whiteList = { "patch.MPQ", "patch-2.MPQ", "patch-3.MPQ", "lichking.MPQ",
"expansion.MPQ", "common.MPQ", "common-2.MPQ"};
for (int i = 0; i < files.Length; i++)
{
if (!Regex.IsMatch(files[i], ".MPQ") && !Regex.IsMatch(files[i], ".mpq"))
continue;
string fileName = Path.GetFileName(files[i]);
if (shouldPass(fileName, whiteList)) continue;
if (File.Exists(files[i]))
File.Delete(files[i]);
}
}
private static bool shouldPass(string str, string[] whiteList)
{
for (int j = 0; j < whiteList.Length; j++)
if (str == whiteList[j])
return true;
return false;
}
}
}