From 614adb2a31cc91a7cefb37824ccac533c353cf54 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Fri, 9 Aug 2019 20:47:21 -0500 Subject: [PATCH] Don't add unnecessary ".cnmt" to SwitchFs nca names --- src/LibHac/SwitchFs.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/LibHac/SwitchFs.cs b/src/LibHac/SwitchFs.cs index 6a6e5a24..b3070ec7 100644 --- a/src/LibHac/SwitchFs.cs +++ b/src/LibHac/SwitchFs.cs @@ -80,7 +80,7 @@ namespace LibHac nca = new SwitchFsNca(new Nca(Keyset, storage)); - nca.NcaId = Path.GetFileNameWithoutExtension(fileEntry.Name); + nca.NcaId = GetNcaFilename(fileEntry.Name, nca); string extension = nca.Nca.Header.ContentType == ContentType.Meta ? ".cnmt.nca" : ".nca"; nca.Filename = nca.NcaId + extension; } @@ -227,6 +227,16 @@ namespace LibHac } } + private string GetNcaFilename(string name, SwitchFsNca nca) + { + if (nca.Nca.Header.ContentType != ContentType.Meta || !name.EndsWith(".cnmt.nca")) + { + return Path.GetFileNameWithoutExtension(name); + } + + return name.Substring(0, name.Length - ".cnmt.nca".Length); + } + private void DisposeNcas() { //foreach (SwitchFsNca nca in Ncas.Values)