added support for modpack defined in version descriptor
This commit is contained in:
32
Mlaumcherb.Client.Avalonia/холопы/HashHelper.cs
Normal file
32
Mlaumcherb.Client.Avalonia/холопы/HashHelper.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Security.Cryptography;
|
||||
using DTLib.Extensions;
|
||||
|
||||
namespace Mlaumcherb.Client.Avalonia.холопы;
|
||||
|
||||
public static class HashHelper
|
||||
{
|
||||
private static SHA1 _hasher;
|
||||
|
||||
static HashHelper()
|
||||
{
|
||||
_hasher = SHA1.Create();
|
||||
}
|
||||
|
||||
public static string HashFileSHA1(IOPath f)
|
||||
{
|
||||
using var fs = File.OpenRead(f);
|
||||
byte[] hash = _hasher.ComputeHash(fs);
|
||||
return hash.HashToString();
|
||||
}
|
||||
|
||||
public static bool CheckFileSHA1(IOPath f, string? sha1, bool checkHash)
|
||||
{
|
||||
if (!File.Exists(f))
|
||||
return false;
|
||||
|
||||
if(checkHash)
|
||||
return sha1 is not null && HashFileSHA1(f) == sha1;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -54,4 +54,10 @@ public static class PathHelper
|
||||
|
||||
public static IOPath GetLog4jConfigFilePath() =>
|
||||
Path.Concat(GetAssetsDir(), GetLog4jConfigFileName());
|
||||
|
||||
public static IOPath GetModpackDescriptorPath(string game_version) =>
|
||||
Path.Concat(GetVersionDir(game_version), "timerix_modpack.json");
|
||||
|
||||
public static IOPath GetModpackManifestPath(string game_version) =>
|
||||
Path.Concat(GetVersionDir(game_version), "timerix_modpack_files.json");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user