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
This commit is contained in:
Alex Barney 2019-10-17 01:17:44 -05:00 committed by Ac_K
parent c0fe6cdca0
commit 8a8ea4c8c0
18 changed files with 353 additions and 404 deletions

View file

@ -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;
}
byte[] data = new byte[firmwareFile.GetSize()];
result = firmwareFile.GetSize(out long fileSize);
if (result.IsFailure())
{
return null;
}
firmwareFile.Read(data, 0);
byte[] data = new byte[fileSize];
result = firmwareFile.Read(out _, 0, data);
if (result.IsFailure())
{
return null;
}
return data;
}