From 8a8ea4c8c00e8ba23349d9cdb0a6b681d09e6b0d Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Thu, 17 Oct 2019 01:17:44 -0500 Subject: Update to LibHac 0.6.0 (#792) * Update to LibHac 0.6.0 * Create an IFileSystemProxy object from LibHac * Rename rc -> result * Alignment and spacing * Result formatting * Spacing * Sort usings --- .../HOS/Services/Settings/ISystemSettingsServer.cs | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'Ryujinx.HLE/HOS/Services/Settings') diff --git a/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs b/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs index 7af78dbf..490d0e8e 100644 --- a/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs +++ b/Ryujinx.HLE/HOS/Services/Settings/ISystemSettingsServer.cs @@ -1,5 +1,7 @@ +using LibHac; using LibHac.Fs; -using LibHac.Fs.NcaUtils; +using LibHac.FsSystem; +using LibHac.FsSystem.NcaUtils; using Ryujinx.Common.Logging; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS.SystemState; @@ -165,7 +167,7 @@ namespace Ryujinx.HLE.HOS.Services.Settings public byte[] GetFirmwareData(Switch device) { long titleId = 0x0100000000000809; - string contentPath = device.System.ContentManager.GetInstalledContentPath(titleId, StorageId.NandSystem, ContentType.Data); + string contentPath = device.System.ContentManager.GetInstalledContentPath(titleId, StorageId.NandSystem, NcaContentType.Data); if (string.IsNullOrWhiteSpace(contentPath)) { @@ -185,11 +187,25 @@ namespace Ryujinx.HLE.HOS.Services.Settings IFileSystem firmwareRomFs = firmwareContent.OpenFileSystem(NcaSectionType.Data, device.System.FsIntegrityCheckLevel); - IFile firmwareFile = firmwareRomFs.OpenFile("/file", OpenMode.Read); + Result result = firmwareRomFs.OpenFile(out IFile firmwareFile, "/file", OpenMode.Read); + if (result.IsFailure()) + { + return null; + } + + result = firmwareFile.GetSize(out long fileSize); + if (result.IsFailure()) + { + return null; + } - byte[] data = new byte[firmwareFile.GetSize()]; + byte[] data = new byte[fileSize]; - firmwareFile.Read(data, 0); + result = firmwareFile.Read(out _, 0, data); + if (result.IsFailure()) + { + return null; + } return data; } -- cgit v1.2.3