30 lines
967 B
C#
30 lines
967 B
C#
using Mlaumcherb.Client.Avalonia.холопы;
|
||
|
||
namespace Mlaumcherb.Client.Avalonia.классы;
|
||
|
||
public class ModpackFilesManifest
|
||
{
|
||
public class FileProps
|
||
{
|
||
[JsonRequired] public string sha1 { get; set; } = "";
|
||
public bool allow_edit { get; set; } = false;
|
||
}
|
||
|
||
/// relative_path, hash
|
||
[JsonRequired] public Dictionary<string, FileProps> files { get; set; } = new();
|
||
|
||
public bool CheckFiles(IOPath basedir, bool checkHashes, HashSet<IOPath> unmatchedFilesLocalPaths)
|
||
{
|
||
foreach (var p in files)
|
||
{
|
||
var localPath = new IOPath(p.Key);
|
||
var realPath = Path.Concat(basedir, localPath);
|
||
if (!HashHelper.CheckFileSHA1(realPath, p.Value.sha1, checkHashes && !p.Value.allow_edit))
|
||
{
|
||
unmatchedFilesLocalPaths.Add(localPath);
|
||
}
|
||
}
|
||
|
||
return unmatchedFilesLocalPaths.Count == 0;
|
||
}
|
||
} |