Installer/Aki.Helper/PreCheckHelper.cs

56 lines
1.9 KiB
C#
Raw Normal View History

using Microsoft.Win32;
using System.Runtime.InteropServices;
using System.IO;
using System.Diagnostics;
namespace SPT_AKI_Installer.Aki.Helper
{
2022-05-19 14:41:44 +01:00
public static class PreCheckHelper
{
private const string registryInstall = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov";
2022-05-19 14:41:44 +01:00
public static string DetectOriginalGamePath()
{
// We can't detect the installed path on non-Windows
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
return null;
var uninstallStringValue = Registry.LocalMachine.OpenSubKey(registryInstall, false)
?.GetValue("UninstallString");
var info = (uninstallStringValue is string key) ? new FileInfo(key) : null;
2022-07-09 00:33:55 -04:00
return info?.DirectoryName;
}
2022-07-09 00:33:55 -04:00
public static string DetectOriginalGameVersion(string gamePath)
{
2022-07-09 00:33:55 -04:00
return FileVersionInfo.GetVersionInfo(Path.Join(gamePath + "/EscapeFromTarkov.exe")).ProductVersion.Replace('-', '.').Split('.')[^2];
}
2022-07-09 13:08:41 -04:00
//public static string GetPatcherZipPath(string gameVersion, string targetPath)
//{
// // example patch name - Patcher.12.12.15.17861.to.12.12.15.17349.zip
// var patchZip = FileHelper.FindFile(targetPath, gameVersion, "Patcher");
// if (patchZip == null)
// {
// patchZip = FileHelper.FindFile(targetPath, "PATCHERZIP");
// }
2022-07-09 00:33:55 -04:00
2022-07-09 13:08:41 -04:00
// return patchZip;
//}
2022-05-19 14:41:44 +01:00
2022-07-09 13:08:41 -04:00
//public static string GetAkiZipPath(string targetPath)
//{
// // example aki name - RELEASE-SPT-2.3.1-17349.zip
// var akiZip = FileHelper.FindFile(targetPath, "SPT", "RELEASE");
2022-07-09 00:33:55 -04:00
2022-07-09 13:08:41 -04:00
// if (akiZip == null)
// {
// akiZip = FileHelper.FindFile(targetPath, "AKIZIP");
// }
2022-07-09 00:33:55 -04:00
2022-07-09 13:08:41 -04:00
// return akiZip;
//}
}
}