mirror of
https://github.com/kwsch/NHSE.git
synced 2026-07-13 06:41:02 -05:00
56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using System.IO;
|
|
|
|
namespace NHSE.Core
|
|
{
|
|
/// <summary>
|
|
/// Logic for dumping raw game files.
|
|
/// </summary>
|
|
public static class GameFileDumper
|
|
{
|
|
/// <summary>
|
|
/// Dumps a copy of the <see cref="sav"/>'s files in their decrypted state to the requested <see cref="path"/>.
|
|
/// </summary>
|
|
/// <param name="sav">Save Data to dump</param>
|
|
/// <param name="path">Path to dump to</param>
|
|
public static void Dump(this HorizonSave sav, string path)
|
|
{
|
|
sav.Main.Dump(path);
|
|
foreach (var p in sav.Players)
|
|
{
|
|
var dir = Path.Combine(path, p.DirectoryName);
|
|
p.Dump(dir);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dumps a copy of the <see cref="player"/>'s files in their decrypted state to the requested <see cref="path"/>.
|
|
/// </summary>
|
|
/// <param name="player">Save Data to dump</param>
|
|
/// <param name="path">Path to dump to</param>
|
|
public static void Dump(this Player player, string path)
|
|
{
|
|
player.Profile.Dump(path);
|
|
player.Personal.Dump(path);
|
|
player.Photo.Dump(path);
|
|
player.PostBox.Dump(path);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dumps a copy of the <see cref="pair"/>'s files in their decrypted state to the requested <see cref="path"/>.
|
|
/// </summary>
|
|
/// <param name="pair">Save Data to dump</param>
|
|
/// <param name="path">Path to dump to</param>
|
|
public static void Dump(this EncryptedFilePair pair, string path)
|
|
{
|
|
Dump(path, pair.Data, pair.NameData);
|
|
}
|
|
|
|
private static void Dump(string path, byte[] data, string name)
|
|
{
|
|
Directory.CreateDirectory(path);
|
|
var file = Path.Combine(path, name);
|
|
File.WriteAllBytes(file, data);
|
|
}
|
|
}
|
|
}
|