mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-15 19:22:19 +08:00
parent
f232a75a40
commit
b267d6493b
|
@ -117,13 +117,18 @@ namespace BililiveRecorder.Cli
|
|||
|
||||
path = Path.GetFullPath(path);
|
||||
|
||||
ConfigV3? config;
|
||||
|
||||
if (args.ConfigOverride is not null)
|
||||
{
|
||||
logger.Information("Using config from {ConfigOverride}", args.ConfigOverride);
|
||||
path = args.ConfigOverride;
|
||||
config = ConfigParser.LoadFromFile(args.ConfigOverride);
|
||||
}
|
||||
else
|
||||
{
|
||||
config = ConfigParser.LoadFromDirectory(path);
|
||||
}
|
||||
|
||||
var config = ConfigParser.LoadFrom(path);
|
||||
if (config is null)
|
||||
{
|
||||
logger.Error("Config Loading Failed");
|
||||
|
|
|
@ -18,26 +18,31 @@ namespace BililiveRecorder.Core.Config
|
|||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
public static V3.ConfigV3? LoadFrom(string directory)
|
||||
public static V3.ConfigV3? LoadFromDirectory(string directory)
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
logger.Warning("目标文件夹不存在");
|
||||
return null;
|
||||
}
|
||||
|
||||
var path = Path.Combine(directory, CONFIG_FILE_NAME);
|
||||
|
||||
return LoadFromFile(path);
|
||||
}
|
||||
|
||||
public static V3.ConfigV3? LoadFromFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
logger.Warning("目标文件夹不存在");
|
||||
return null;
|
||||
}
|
||||
|
||||
var filepath = Path.Combine(directory, CONFIG_FILE_NAME);
|
||||
|
||||
if (!File.Exists(filepath))
|
||||
{
|
||||
logger.Information("初始化默认设置,因为配置文件不存在 {Path}", filepath);
|
||||
logger.Information("初始化默认设置,因为配置文件不存在 {Path}", path);
|
||||
return new V3.ConfigV3();
|
||||
}
|
||||
|
||||
logger.Debug("Loading config from {Path}", filepath);
|
||||
var json = File.ReadAllText(filepath, Encoding.UTF8);
|
||||
logger.Debug("Loading config from {Path}", path);
|
||||
var json = File.ReadAllText(path, Encoding.UTF8);
|
||||
return LoadJson(json);
|
||||
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ You can uninstall me in system settings.", "安装成功 Installed", MessageBoxB
|
|||
catch (Exception) { }
|
||||
|
||||
// 加载配置文件
|
||||
var config = ConfigParser.LoadFrom(path);
|
||||
var config = ConfigParser.LoadFromDirectory(path);
|
||||
if (config is null)
|
||||
{
|
||||
error = WorkDirectorySelectorDialog.WorkDirectorySelectorDialogError.FailedToLoadConfig;
|
||||
|
|
|
@ -30,10 +30,11 @@ namespace BililiveRecorder.Core.Config
|
|||
{
|
||||
public const string CONFIG_FILE_NAME = "config.json";
|
||||
public ConfigParser() { }
|
||||
public static BililiveRecorder.Core.Config.V3.ConfigV3? LoadFrom(string directory) { }
|
||||
public static BililiveRecorder.Core.Config.V3.ConfigV3? LoadFromDirectory(string directory) { }
|
||||
public static BililiveRecorder.Core.Config.V3.ConfigV3? LoadFromFile(string path) { }
|
||||
public static BililiveRecorder.Core.Config.V3.ConfigV3? LoadJson(string json) { }
|
||||
public static bool Save(BililiveRecorder.Core.Config.V3.ConfigV3 config) { }
|
||||
public static string? SaveJson(BililiveRecorder.Core.Config.V3.ConfigV3 config) { }
|
||||
public static bool SaveTo(string directory, BililiveRecorder.Core.Config.V3.ConfigV3 config) { }
|
||||
public static void WriteAllTextWithBackup(string path, string contents) { }
|
||||
}
|
||||
public enum CuttingMode
|
||||
|
@ -61,6 +62,8 @@ namespace BililiveRecorder.Core.Config.V3
|
|||
{
|
||||
public ConfigV3() { }
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public string? ConfigPathOverride { get; set; }
|
||||
[Newtonsoft.Json.JsonIgnore]
|
||||
public bool DisableConfigSave { get; set; }
|
||||
[Newtonsoft.Json.JsonProperty("global")]
|
||||
public BililiveRecorder.Core.Config.V3.GlobalConfig Global { get; set; }
|
||||
|
|
Loading…
Reference in New Issue
Block a user