-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
50 lines (45 loc) · 1.79 KB
/
Program.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
using System;
using System.IO;
namespace MassiveAssaultScnFixer
{
class Program
{
private const string ScenariosFolderName = "scenarios";
private const string ScenariosBackupFolderName = "scenarios_backup";
static void Main(string[] args)
{
var gameFolder = args[0];
FixFilesInFolder(gameFolder);
}
private static void FixFilesInFolder(string gameFolder)
{
var scenariosFolder = Path.Combine(gameFolder, ScenariosFolderName);
BackupScenarios(gameFolder, scenariosFolder);
var files = Directory.GetFiles(scenariosFolder, "*.scn", SearchOption.AllDirectories);
foreach (var file in files)
{
try
{
var fixer = new FileFixer(file);
fixer.Fix();
Console.WriteLine($"Scenario is fixed: {file}");
}
catch (Exception e)
{
Console.WriteLine($"Failed on fixing scenario: {file}");
Console.WriteLine(e);
}
}
}
private static void BackupScenarios(string gameFolder, string scenariosFolder)
{
var backupFolder = Path.Combine(gameFolder, ScenariosBackupFolderName);
foreach (string dirPath in Directory.GetDirectories(scenariosFolder, "*",
SearchOption.AllDirectories))
Directory.CreateDirectory(dirPath.Replace(scenariosFolder, backupFolder));
foreach (string newPath in Directory.GetFiles(scenariosFolder, "*.*",
SearchOption.AllDirectories))
File.Copy(newPath, newPath.Replace(scenariosFolder, backupFolder), true);
}
}
}