mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-19 06:55:59 +01:00
Write settings, presets and favourites whole or not at all
A failed write leaves the old file in place. Settings that could not be read are not saved over. UI exceptions reach the log. Started from a shortcut set up elsewhere, the starter moves to its own folder when only that one holds a game.
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
@@ -53,6 +55,25 @@ public static class Diagnostics
|
||||
Dispatcher.UIThread.Post(() => _ = ReportAsync(message, title));
|
||||
}
|
||||
|
||||
/// <summary>Opens a file or folder the way the system does; a dialog says if it is not there or will not open.</summary>
|
||||
public static void OpenOrReport(string path)
|
||||
{
|
||||
if (!File.Exists(path) && !Directory.Exists(path))
|
||||
{
|
||||
ReportOnUiThread(string.Format(App.Loc["FaultFileNotFound"], path));
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo(path) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_ = ReportAsync(path, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static InstallationCheck InstallationCheck() =>
|
||||
new(AppServices.Current.Paths,
|
||||
AppServices.Current.Files,
|
||||
|
||||
Reference in New Issue
Block a user