2022-05-14 12:19:40 +01:00
|
|
|
|
using System.Diagnostics;
|
2022-07-09 00:33:55 -04:00
|
|
|
|
using SPT_AKI_Installer.Aki.Core.Model;
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-05-14 02:58:38 +01:00
|
|
|
|
namespace SPT_AKI_Installer.Aki.Helper
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-07-09 00:33:55 -04:00
|
|
|
|
public enum PatcherExitCode
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-07-09 00:33:55 -04:00
|
|
|
|
ProgramClosed = 0,
|
|
|
|
|
Success = 10,
|
|
|
|
|
EftExeNotFound = 11,
|
|
|
|
|
NoPatchFolder = 12,
|
|
|
|
|
MissingFile = 13,
|
|
|
|
|
MissingDir = 14,
|
|
|
|
|
PatchFailed = 15
|
|
|
|
|
}
|
2022-05-13 22:41:15 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
public class ProcessHelper
|
|
|
|
|
{
|
|
|
|
|
public GenericResult PatchClientFiles(string exeDir, string workingDir)
|
2022-05-13 22:41:15 +01:00
|
|
|
|
{
|
2022-07-09 00:33:55 -04:00
|
|
|
|
var process = new Process();
|
|
|
|
|
process.StartInfo.FileName = exeDir;
|
|
|
|
|
process.StartInfo.WorkingDirectory = workingDir;
|
|
|
|
|
process.EnableRaisingEvents = true;
|
|
|
|
|
process.StartInfo.Arguments = "autoclose";
|
|
|
|
|
process.Start();
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
process.WaitForExit();
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
switch ((PatcherExitCode)process.ExitCode)
|
2022-05-19 14:41:44 +01:00
|
|
|
|
{
|
2022-07-09 00:33:55 -04:00
|
|
|
|
case PatcherExitCode.Success:
|
|
|
|
|
return GenericResult.FromSuccess("Patcher Finished Successfully, extracting Aki");
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
case PatcherExitCode.ProgramClosed:
|
|
|
|
|
return GenericResult.FromError("Patcher was closed before completing!");
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
case PatcherExitCode.EftExeNotFound:
|
|
|
|
|
return GenericResult.FromError("EscapeFromTarkov.exe is missing from the install Path");
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
case PatcherExitCode.NoPatchFolder:
|
|
|
|
|
return GenericResult.FromError("Patchers Folder called 'Aki_Patches' is missing");
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
case PatcherExitCode.MissingFile:
|
|
|
|
|
return GenericResult.FromError("EFT files was missing a Vital file to continue");
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
case PatcherExitCode.PatchFailed:
|
|
|
|
|
return GenericResult.FromError("A patch failed to apply");
|
2022-05-19 14:41:44 +01:00
|
|
|
|
|
2022-07-09 00:33:55 -04:00
|
|
|
|
default:
|
|
|
|
|
return GenericResult.FromError("an unknown error occurred in the patcher");
|
2022-05-19 14:41:44 +01:00
|
|
|
|
}
|
2022-05-13 22:41:15 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|