From bd65499b079a910073febeff94f172b5cc9daa0d Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 10 Jun 2024 00:32:14 -0500 Subject: [PATCH] Update ExeFS.cs --- pk3DS.Core/CTR/ExeFS.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pk3DS.Core/CTR/ExeFS.cs b/pk3DS.Core/CTR/ExeFS.cs index a5cb795..3d14821 100644 --- a/pk3DS.Core/CTR/ExeFS.cs +++ b/pk3DS.Core/CTR/ExeFS.cs @@ -9,26 +9,25 @@ namespace pk3DS.Core.CTR; public class ExeFS { public byte[] Data; - public byte[] SuperBlockHash; + public readonly byte[] SuperBlockHash; // Return an object with data stored in a byte array - public ExeFS(string EXEFS_PATH) + public ExeFS(string path) { - if (Directory.Exists(EXEFS_PATH)) + if (Directory.Exists(path)) { - var files = new DirectoryInfo(EXEFS_PATH).GetFiles().Select(f => f.FullName).ToArray(); + var files = new DirectoryInfo(path).GetFiles().Select(f => f.FullName).ToArray(); SetData(files); } + else if (File.Exists(path)) + { + Data = File.ReadAllBytes(path); + } else { - Data = File.ReadAllBytes(EXEFS_PATH); + throw new FileNotFoundException("File not found.", path); } - GetSuperBlockHash(); - } - - public void GetSuperBlockHash() - { - SHA256.HashData(Data.AsSpan(0, 200), SuperBlockHash); + SuperBlockHash = SHA256.HashData(Data.AsSpan(0, 200)); } // Overall R/W files (wrapped)