Rename SaveFS and Savefile classes

This commit is contained in:
Alex Barney 2018-12-11 13:59:35 -06:00
parent 4a65a5da20
commit b5c9e13df3
7 changed files with 25 additions and 25 deletions

View file

@ -4,14 +4,14 @@ using System.IO;
namespace LibHac.IO.Save namespace LibHac.IO.Save
{ {
public class Savefile : IDisposable public class SaveData : IDisposable
{ {
public Header Header { get; } public Header Header { get; }
public IStorage BaseStorage { get; } public IStorage BaseStorage { get; }
public bool LeaveOpen { get; } public bool LeaveOpen { get; }
public HierarchicalIntegrityVerificationStorage IvfcStorage { get; } public HierarchicalIntegrityVerificationStorage IvfcStorage { get; }
public SaveFs SaveFs { get; } public SaveDataFileSystemCore SaveDataFileSystemCore { get; }
public RemapStorage DataRemapStorage { get; } public RemapStorage DataRemapStorage { get; }
public RemapStorage MetaRemapStorage { get; } public RemapStorage MetaRemapStorage { get; }
@ -19,11 +19,11 @@ namespace LibHac.IO.Save
public HierarchicalDuplexStorage DuplexStorage { get; } public HierarchicalDuplexStorage DuplexStorage { get; }
public JournalStorage JournalStorage { get; } public JournalStorage JournalStorage { get; }
public DirectoryEntry RootDirectory => SaveFs.RootDirectory; public DirectoryEntry RootDirectory => SaveDataFileSystemCore.RootDirectory;
public FileEntry[] Files => SaveFs.Files; public FileEntry[] Files => SaveDataFileSystemCore.Files;
public DirectoryEntry[] Directories => SaveFs.Directories; public DirectoryEntry[] Directories => SaveDataFileSystemCore.Directories;
public Savefile(Keyset keyset, IStorage storage, IntegrityCheckLevel integrityCheckLevel, bool leaveOpen) public SaveData(Keyset keyset, IStorage storage, IntegrityCheckLevel integrityCheckLevel, bool leaveOpen)
{ {
BaseStorage = storage; BaseStorage = storage;
LeaveOpen = leaveOpen; LeaveOpen = leaveOpen;
@ -63,7 +63,7 @@ namespace LibHac.IO.Save
fatStorage = InitFatIvfcStorage(integrityCheckLevel); fatStorage = InitFatIvfcStorage(integrityCheckLevel);
} }
SaveFs = new SaveFs(IvfcStorage, fatStorage, Header.SaveHeader); SaveDataFileSystemCore = new SaveDataFileSystemCore(IvfcStorage, fatStorage, Header.SaveHeader);
} }
private static HierarchicalDuplexStorage InitDuplexStorage(IStorage baseStorage, Header header) private static HierarchicalDuplexStorage InitDuplexStorage(IStorage baseStorage, Header header)
@ -121,15 +121,15 @@ namespace LibHac.IO.Save
public IStorage OpenFile(string filename) public IStorage OpenFile(string filename)
{ {
return SaveFs.OpenFile(filename); return SaveDataFileSystemCore.OpenFile(filename);
} }
public IStorage OpenFile(FileEntry file) public IStorage OpenFile(FileEntry file)
{ {
return SaveFs.OpenFile(file); return SaveDataFileSystemCore.OpenFile(file);
} }
public bool FileExists(string filename) => SaveFs.FileExists(filename); public bool FileExists(string filename) => SaveDataFileSystemCore.FileExists(filename);
public bool CommitHeader(Keyset keyset) public bool CommitHeader(Keyset keyset)
{ {
@ -187,7 +187,7 @@ namespace LibHac.IO.Save
public static class SavefileExtensions public static class SavefileExtensions
{ {
public static void Extract(this Savefile save, string outDir, IProgressReport logger = null) public static void Extract(this SaveData save, string outDir, IProgressReport logger = null)
{ {
foreach (FileEntry file in save.Files) foreach (FileEntry file in save.Files)
{ {

View file

@ -3,7 +3,7 @@ using System.IO;
namespace LibHac.IO.Save namespace LibHac.IO.Save
{ {
public class SaveFs public class SaveDataFileSystemCore
{ {
private IStorage BaseStorage { get; } private IStorage BaseStorage { get; }
private IStorage HeaderStorage { get; } private IStorage HeaderStorage { get; }
@ -16,7 +16,7 @@ namespace LibHac.IO.Save
public DirectoryEntry[] Directories { get; private set; } public DirectoryEntry[] Directories { get; private set; }
public Dictionary<string, FileEntry> FileDictionary { get; } public Dictionary<string, FileEntry> FileDictionary { get; }
public SaveFs(IStorage storage, IStorage allocationTable, IStorage header) public SaveDataFileSystemCore(IStorage storage, IStorage allocationTable, IStorage header)
{ {
HeaderStorage = header; HeaderStorage = header;
BaseStorage = storage; BaseStorage = storage;

View file

@ -17,7 +17,7 @@ namespace LibHac
public string SaveDir { get; } public string SaveDir { get; }
public Dictionary<string, Nca> Ncas { get; } = new Dictionary<string, Nca>(StringComparer.OrdinalIgnoreCase); public Dictionary<string, Nca> Ncas { get; } = new Dictionary<string, Nca>(StringComparer.OrdinalIgnoreCase);
public Dictionary<string, Savefile> Saves { get; } = new Dictionary<string, Savefile>(StringComparer.OrdinalIgnoreCase); public Dictionary<string, SaveData> Saves { get; } = new Dictionary<string, SaveData>(StringComparer.OrdinalIgnoreCase);
public Dictionary<ulong, Title> Titles { get; } = new Dictionary<ulong, Title>(); public Dictionary<ulong, Title> Titles { get; } = new Dictionary<ulong, Title>();
public Dictionary<ulong, Application> Applications { get; } = new Dictionary<ulong, Application>(); public Dictionary<ulong, Application> Applications { get; } = new Dictionary<ulong, Application>();
@ -118,7 +118,7 @@ namespace LibHac
foreach (string file in files) foreach (string file in files)
{ {
Savefile save = null; SaveData save = null;
string saveName = Path.GetFileNameWithoutExtension(file); string saveName = Path.GetFileNameWithoutExtension(file);
try try
@ -127,7 +127,7 @@ namespace LibHac
string sdPath = "/" + Util.GetRelativePath(file, SaveDir).Replace('\\', '/'); string sdPath = "/" + Util.GetRelativePath(file, SaveDir).Replace('\\', '/');
var nax0 = new Nax0(Keyset, storage, sdPath, false); var nax0 = new Nax0(Keyset, storage, sdPath, false);
save = new Savefile(Keyset, nax0.BaseStorage, IntegrityCheckLevel.None, true); save = new SaveData(Keyset, nax0.BaseStorage, IntegrityCheckLevel.None, true);
} }
catch (Exception ex) catch (Exception ex)
{ {

View file

@ -103,7 +103,7 @@ namespace NandReader
private static List<Ticket> ReadTickets(Keyset keyset, Stream savefile) private static List<Ticket> ReadTickets(Keyset keyset, Stream savefile)
{ {
var tickets = new List<Ticket>(); var tickets = new List<Ticket>();
var save = new Savefile(keyset, savefile.AsStorage(), IntegrityCheckLevel.None, true); var save = new SaveData(keyset, savefile.AsStorage(), IntegrityCheckLevel.None, true);
var ticketList = new BinaryReader(save.OpenFile("/ticket_list.bin").AsStream()); var ticketList = new BinaryReader(save.OpenFile("/ticket_list.bin").AsStream());
var ticketFile = new BinaryReader(save.OpenFile("/ticket.bin").AsStream()); var ticketFile = new BinaryReader(save.OpenFile("/ticket.bin").AsStream());

View file

@ -87,7 +87,7 @@ namespace NandReaderGui.ViewModel
private static List<Ticket> ReadTickets(Keyset keyset, Stream savefile) private static List<Ticket> ReadTickets(Keyset keyset, Stream savefile)
{ {
var tickets = new List<Ticket>(); var tickets = new List<Ticket>();
var save = new Savefile(keyset, savefile.AsStorage(), IntegrityCheckLevel.None, true); var save = new SaveData(keyset, savefile.AsStorage(), IntegrityCheckLevel.None, true);
var ticketList = new BinaryReader(save.OpenFile("/ticket_list.bin").AsStream()); var ticketList = new BinaryReader(save.OpenFile("/ticket_list.bin").AsStream());
var ticketFile = new BinaryReader(save.OpenFile("/ticket.bin").AsStream()); var ticketFile = new BinaryReader(save.OpenFile("/ticket.bin").AsStream());

View file

@ -14,7 +14,7 @@ namespace hactoolnet
{ {
using (var file = new FileStream(ctx.Options.InFile, FileMode.Open, FileAccess.ReadWrite)) using (var file = new FileStream(ctx.Options.InFile, FileMode.Open, FileAccess.ReadWrite))
{ {
var save = new Savefile(ctx.Keyset, file.AsStorage(), ctx.Options.IntegrityLevel, true); var save = new SaveData(ctx.Keyset, file.AsStorage(), ctx.Options.IntegrityLevel, true);
if (ctx.Options.Validate) if (ctx.Options.Validate)
{ {
@ -62,10 +62,10 @@ namespace hactoolnet
string saveDir = Path.Combine(dir, "save"); string saveDir = Path.Combine(dir, "save");
Directory.CreateDirectory(saveDir); Directory.CreateDirectory(saveDir);
save.SaveFs.GetHeaderStorage().WriteAllBytes(Path.Combine(saveDir, "Save_Header")); save.SaveDataFileSystemCore.GetHeaderStorage().WriteAllBytes(Path.Combine(saveDir, "Save_Header"));
save.SaveFs.GetBaseStorage().WriteAllBytes(Path.Combine(saveDir, "Save_Data")); save.SaveDataFileSystemCore.GetBaseStorage().WriteAllBytes(Path.Combine(saveDir, "Save_Data"));
save.SaveFs.AllocationTable.GetHeaderStorage().WriteAllBytes(Path.Combine(saveDir, "FAT_header")); save.SaveDataFileSystemCore.AllocationTable.GetHeaderStorage().WriteAllBytes(Path.Combine(saveDir, "FAT_header"));
save.SaveFs.AllocationTable.GetBaseStorage().WriteAllBytes(Path.Combine(saveDir, "FAT_Data")); save.SaveDataFileSystemCore.AllocationTable.GetBaseStorage().WriteAllBytes(Path.Combine(saveDir, "FAT_Data"));
save.Header.DataIvfcMaster.WriteAllBytes(Path.Combine(saveDir, "Save_MasterHash")); save.Header.DataIvfcMaster.WriteAllBytes(Path.Combine(saveDir, "Save_MasterHash"));
@ -118,7 +118,7 @@ namespace hactoolnet
} }
} }
private static string Print(this Savefile save) private static string Print(this SaveData save)
{ {
int colLen = 25; int colLen = 25;
var sb = new StringBuilder(); var sb = new StringBuilder();

View file

@ -286,7 +286,7 @@ namespace hactoolnet
private static void ExportSdSaves(Context ctx, SwitchFs switchFs) private static void ExportSdSaves(Context ctx, SwitchFs switchFs)
{ {
foreach (KeyValuePair<string, Savefile> save in switchFs.Saves) foreach (KeyValuePair<string, SaveData> save in switchFs.Saves)
{ {
string outDir = Path.Combine(ctx.Options.SaveOutDir, save.Key); string outDir = Path.Combine(ctx.Options.SaveOutDir, save.Key);
save.Value.Extract(outDir, ctx.Logger); save.Value.Extract(outDir, ctx.Logger);