33 lines
924 B
C#
33 lines
924 B
C#
using Microsoft.VisualBasic.CompilerServices;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
namespace ModpackUpdater.Model;
|
|
|
|
public class ModpackInfo
|
|
{
|
|
private const string FILENAME_MODPACKINFO = "modpack-info.json";
|
|
|
|
[JsonConverter(typeof(VersionConverter))]
|
|
public Version Version { get; set; }
|
|
|
|
public void Save(string mcRoot)
|
|
{
|
|
File.WriteAllText(Conversions.ToString(GetFilePath(mcRoot)), JsonConvert.SerializeObject(this));
|
|
}
|
|
|
|
public static ModpackInfo Load(string mcRoot)
|
|
{
|
|
return JsonConvert.DeserializeObject<ModpackInfo>(File.ReadAllText(Conversions.ToString(GetFilePath(mcRoot))));
|
|
}
|
|
|
|
public static bool HasModpackInfo(string mcRoot)
|
|
{
|
|
return File.Exists(Conversions.ToString(GetFilePath(mcRoot)));
|
|
}
|
|
|
|
private static object GetFilePath(string mcRoot)
|
|
{
|
|
return Path.Combine(mcRoot, FILENAME_MODPACKINFO);
|
|
}
|
|
} |