mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-29 20:03:41 +01:00
fix: save config + manifests by first writing them to another file and moving them over
Should hopefully make corrupted configs a bit more rare
This commit is contained in:
parent
111eea290c
commit
86181cd2d4
4 changed files with 22 additions and 6 deletions
|
|
@ -568,6 +568,22 @@ public static class Util
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overwrite text in a file by first writing it to a temporary file, and then
|
||||
/// moving that file to the path specified.
|
||||
/// </summary>
|
||||
/// <param name="path">The path of the file to write to.</param>
|
||||
/// <param name="text">The text to write.</param>
|
||||
internal static void WriteAllTextSafe(string path, string text)
|
||||
{
|
||||
var tmpPath = path + ".tmp";
|
||||
if (File.Exists(tmpPath))
|
||||
File.Delete(tmpPath);
|
||||
|
||||
File.WriteAllText(tmpPath, text);
|
||||
File.Move(tmpPath, path, true);
|
||||
}
|
||||
|
||||
private static unsafe void ShowValue(ulong addr, IEnumerable<string> path, Type type, object value)
|
||||
{
|
||||
if (type.IsPointer)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue