From 290f5e812e68e47d95aba0cc3789a4bc6d04c7ce Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Fri, 4 Jan 2019 17:41:49 -0700 Subject: Update to LibHac 0.2.0 (#549) * Update to LibHac 0.2.0 * Changes based on feedback --- Ryujinx.HLE/HOS/Font/SharedFontManager.cs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'Ryujinx.HLE/HOS/Font') diff --git a/Ryujinx.HLE/HOS/Font/SharedFontManager.cs b/Ryujinx.HLE/HOS/Font/SharedFontManager.cs index 31c8178a..9eb2c7e5 100644 --- a/Ryujinx.HLE/HOS/Font/SharedFontManager.cs +++ b/Ryujinx.HLE/HOS/Font/SharedFontManager.cs @@ -1,4 +1,5 @@ using LibHac; +using LibHac.IO; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.FileSystem.Content; using Ryujinx.HLE.Resource; @@ -67,14 +68,18 @@ namespace Ryujinx.HLE.HOS.Font fileIndex = 1; } - FileStream ncaFileStream = new FileStream(fontPath, FileMode.Open, FileAccess.Read); - Nca nca = new Nca(_device.System.KeySet, ncaFileStream, false); - NcaSection romfsSection = nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs); - Romfs romfs = new Romfs(nca.OpenSection(romfsSection.SectionNum, false, _device.System.FsIntegrityCheckLevel)); - Stream fontFile = romfs.OpenFile(romfs.Files[fileIndex]); - - byte[] data = DecryptFont(fontFile); + byte[] data; + + using (FileStream ncaFileStream = new FileStream(fontPath, FileMode.Open, FileAccess.Read)) + { + Nca nca = new Nca(_device.System.KeySet, ncaFileStream.AsStorage(), false); + NcaSection romfsSection = nca.Sections.FirstOrDefault(x => x?.Type == SectionType.Romfs); + Romfs romfs = new Romfs(nca.OpenSection(romfsSection.SectionNum, false, _device.System.FsIntegrityCheckLevel, false)); + Stream fontFile = romfs.OpenFile(romfs.Files[fileIndex]).AsStream(); + data = DecryptFont(fontFile); + } + FontInfo info = new FontInfo((int)fontOffset, data.Length); WriteMagicAndSize(_physicalAddress + fontOffset, data.Length); @@ -88,9 +93,6 @@ namespace Ryujinx.HLE.HOS.Font _device.Memory.WriteByte(_physicalAddress + fontOffset, data[fontOffset - start]); } - ncaFileStream.Dispose(); - nca.Dispose(); - return info; } } -- cgit v1.2.3