-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReqMaker.cs
56 lines (48 loc) · 1.81 KB
/
ReqMaker.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
52
53
54
55
56
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace LVLTool
{
public class ReqMaker
{
public static String GetReq(string directory)
{
// config, script, texture, lvl,
StringBuilder builder = new StringBuilder();
builder.Append("ucft\n{\n");
AddFiles(directory, builder, "config");
AddFiles(directory, builder, "script");
AddFiles(directory, builder, "texture");
AddFiles(directory, builder, "loc");
AddFiles(directory, builder, "lvl");
builder.Append("\n}");
return builder.ToString();
}
private static void AddFiles(string directory, StringBuilder builder, string type)
{
string pattern = "*." + type;
List<string> files = GetFiles(directory, pattern);
string file = "";
int lastSlash = 0;
if (files.Count > 0)
{
builder.Append("\n\tREQN\n\t{\n");
builder.Append(String.Format("\t\t\"{0}\"\n", type));
for (int i = 0; i < files.Count; i++)
{
file = files[i].Replace("." + type, "");
lastSlash = file.LastIndexOf("\\") + 1;
file = file.Substring(lastSlash);
builder.Append(String.Format("\t\t\"{0}\"\n", file));
}
builder.Append("\t}\n");
}
}
private static List<string> GetFiles(string directory, string pattern)
{
string[] files = Directory.GetFiles(directory, pattern, SearchOption.TopDirectoryOnly);
return new List<string>(files);
}
}
}