diff options
| author | Alex Barney <thealexbarney@gmail.com> | 2021-12-23 09:55:50 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-23 13:55:50 -0300 |
| commit | aa932a6df1764b7c600ae0ba4e0c7a0ba802f312 (patch) | |
| tree | 24a390cf2330620aeeab1efbd42ae4099f61ca86 /Ryujinx.HLE/HOS/Services/Time | |
| parent | cb43cc7e322014ce2bd0ee73b06d403be62fa8d5 (diff) | |
Update to LibHac v0.14.3 (#2925)
* Update to LibHac v0.14.3
* Fix loading NCAs that don't have a data partition
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Time')
| -rw-r--r-- | Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs index 963ea9fd..4a27bb5f 100644 --- a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs +++ b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs @@ -91,9 +91,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFileStream); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); - romfs.OpenFile(out IFile binaryListFile, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure(); + using var binaryListFile = new UniqueRef<IFile>(); - StreamReader reader = new StreamReader(binaryListFile.AsStream()); + romfs.OpenFile(ref binaryListFile.Ref(), "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure(); + + StreamReader reader = new StreamReader(binaryListFile.Get.AsStream()); List<string> locationNameList = new List<string>(); @@ -135,44 +137,43 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone continue; } - if (romfs.OpenFile(out IFile tzif, $"/zoneinfo/{locName}".ToU8Span(), OpenMode.Read).IsFailure()) + using var tzif = new UniqueRef<IFile>(); + + if (romfs.OpenFile(ref tzif.Ref(), $"/zoneinfo/{locName}".ToU8Span(), OpenMode.Read).IsFailure()) { Logger.Error?.Print(LogClass.ServiceTime, $"Error opening /zoneinfo/{locName}"); continue; } - using (tzif) - { - TimeZone.ParseTimeZoneBinary(out TimeZoneRule tzRule, tzif.AsStream()); + TimeZone.ParseTimeZoneBinary(out TimeZoneRule tzRule, tzif.Get.AsStream()); - TimeTypeInfo ttInfo; - if (tzRule.TimeCount > 0) // Find the current transition period + TimeTypeInfo ttInfo; + if (tzRule.TimeCount > 0) // Find the current transition period + { + int fin = 0; + for (int i = 0; i < tzRule.TimeCount; ++i) { - int fin = 0; - for (int i = 0; i < tzRule.TimeCount; ++i) + if (tzRule.Ats[i] <= now) { - if (tzRule.Ats[i] <= now) - { - fin = i; - } + fin = i; } - ttInfo = tzRule.Ttis[tzRule.Types[fin]]; - } - else if (tzRule.TypeCount >= 1) // Otherwise, use the first offset in TTInfo - { - ttInfo = tzRule.Ttis[0]; - } - else - { - Logger.Error?.Print(LogClass.ServiceTime, $"Couldn't find UTC offset for zone {locName}"); - continue; } + ttInfo = tzRule.Ttis[tzRule.Types[fin]]; + } + else if (tzRule.TypeCount >= 1) // Otherwise, use the first offset in TTInfo + { + ttInfo = tzRule.Ttis[0]; + } + else + { + Logger.Error?.Print(LogClass.ServiceTime, $"Couldn't find UTC offset for zone {locName}"); + continue; + } - var abbrStart = tzRule.Chars.AsSpan(ttInfo.AbbreviationListIndex); - int abbrEnd = abbrStart.IndexOf('\0'); + var abbrStart = tzRule.Chars.AsSpan(ttInfo.AbbreviationListIndex); + int abbrEnd = abbrStart.IndexOf('\0'); - outList.Add((ttInfo.GmtOffset, locName, abbrStart.Slice(0, abbrEnd).ToString())); - } + outList.Add((ttInfo.GmtOffset, locName, abbrStart.Slice(0, abbrEnd).ToString())); } } @@ -262,9 +263,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); - Result result = romfs.OpenFile(out IFile timeZoneBinaryFile, $"/zoneinfo/{locationName}".ToU8Span(), OpenMode.Read); + using var timeZoneBinaryFile = new UniqueRef<IFile>(); + + Result result = romfs.OpenFile(ref timeZoneBinaryFile.Ref(), $"/zoneinfo/{locationName}".ToU8Span(), OpenMode.Read); - timeZoneBinaryStream = timeZoneBinaryFile.AsStream(); + timeZoneBinaryStream = timeZoneBinaryFile.Release().AsStream(); return (ResultCode)result.Value; } |
