Initial commit: Futonizer MKV track stripper

This commit is contained in:
l4kr
2026-07-04 00:43:37 +02:00
commit 1208cadc3b
25 changed files with 2629 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
using System.IO;
using System.Text.Json;
using Futonizer.Models;
namespace Futonizer.Services;
/// <summary>
/// Loads and saves <see cref="AppSettings"/> as a JSON file stored next to
/// the application executable, so it travels with the app folder.
/// </summary>
public static class SettingsService
{
private static readonly string SettingsFilePath = Path.Combine(AppContext.BaseDirectory, "settings.json");
private static readonly JsonSerializerOptions Options = new() { WriteIndented = true };
public static AppSettings Load()
{
try
{
if (File.Exists(SettingsFilePath))
{
string json = File.ReadAllText(SettingsFilePath);
var settings = JsonSerializer.Deserialize<AppSettings>(json, Options);
if (settings is not null)
return settings;
}
}
catch
{
// Corrupt or unreadable settings file - fall back to defaults.
}
return new AppSettings();
}
public static void Save(AppSettings settings)
{
try
{
string json = JsonSerializer.Serialize(settings, Options);
File.WriteAllText(SettingsFilePath, json);
}
catch
{
// Best effort - ignore write failures (e.g. read-only install folder).
}
}
}