diff options
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs')
| -rw-r--r-- | src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs index 9367024e..67cb286a 100644 --- a/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs +++ b/src/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneContentManager.cs @@ -11,7 +11,6 @@ using Ryujinx.Cpu; using Ryujinx.HLE.Exceptions; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS.Services.Time.Clock; -using Ryujinx.HLE.Utilities; using System; using System.Collections.Generic; using System.IO; @@ -24,11 +23,11 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { private const long TimeZoneBinaryTitleId = 0x010000000000080E; - private readonly string TimeZoneSystemTitleMissingErrorMessage = "TimeZoneBinary system title not found! TimeZone conversions will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide#initial-setup-continued---installation-of-firmware for more information)"; + private const string TimeZoneSystemTitleMissingErrorMessage = "TimeZoneBinary system title not found! TimeZone conversions will not work, provide the system archive to fix this error. (See https://github.com/Ryujinx/Ryujinx/wiki/Ryujinx-Setup-&-Configuration-Guide#initial-setup-continued---installation-of-firmware for more information)"; - private VirtualFileSystem _virtualFileSystem; + private VirtualFileSystem _virtualFileSystem; private IntegrityCheckLevel _fsIntegrityCheckLevel; - private ContentManager _contentManager; + private ContentManager _contentManager; public string[] LocationNameCache { get; private set; } @@ -41,8 +40,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public void InitializeInstance(VirtualFileSystem virtualFileSystem, ContentManager contentManager, IntegrityCheckLevel fsIntegrityCheckLevel) { - _virtualFileSystem = virtualFileSystem; - _contentManager = contentManager; + _virtualFileSystem = virtualFileSystem; + _contentManager = contentManager; _fsIntegrityCheckLevel = fsIntegrityCheckLevel; InitializeLocationNameCache(); @@ -90,31 +89,30 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone { if (HasTimeZoneBinaryTitle()) { - using (IStorage ncaFileStream = new LocalStorage(_virtualFileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open)) - { - Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFileStream); - IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); + using IStorage ncaFileStream = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open); - using var binaryListFile = new UniqueRef<IFile>(); + Nca nca = new(_virtualFileSystem.KeySet, ncaFileStream); + IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); - romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure(); + using var binaryListFile = new UniqueRef<IFile>(); - StreamReader reader = new StreamReader(binaryListFile.Get.AsStream()); + romfs.OpenFile(ref binaryListFile.Ref, "/binaryList.txt".ToU8Span(), OpenMode.Read).ThrowIfFailure(); - List<string> locationNameList = new List<string>(); + StreamReader reader = new(binaryListFile.Get.AsStream()); - string locationName; - while ((locationName = reader.ReadLine()) != null) - { - locationNameList.Add(locationName); - } + List<string> locationNameList = new(); - LocationNameCache = locationNameList.ToArray(); + string locationName; + while ((locationName = reader.ReadLine()) != null) + { + locationNameList.Add(locationName); } + + LocationNameCache = locationNameList.ToArray(); } else { - LocationNameCache = new string[] { "UTC" }; + LocationNameCache = new[] { "UTC" }; Logger.Error?.Print(LogClass.ServiceTime, TimeZoneSystemTitleMissingErrorMessage); } @@ -129,9 +127,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone return new[] { (0, "UTC", "UTC") }; } - List<(int Offset, string Location, string Abbr)> outList = new List<(int Offset, string Location, string Abbr)>(); + List<(int Offset, string Location, string Abbr)> outList = new(); var now = DateTimeOffset.Now.ToUnixTimeSeconds(); - using (IStorage ncaStorage = new LocalStorage(_virtualFileSystem.SwitchPathToSystemPath(tzBinaryContentPath), FileAccess.Read, FileMode.Open)) + using (IStorage ncaStorage = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(tzBinaryContentPath), FileAccess.Read, FileMode.Open)) using (IFileSystem romfs = new Nca(_virtualFileSystem.KeySet, ncaStorage).OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel)) { foreach (string locName in LocationNameCache) @@ -149,7 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone continue; } - TimeZoneRuleBox tzRuleBox = new TimeZoneRuleBox(); + TimeZoneRuleBox tzRuleBox = new(); ref TimeZoneRule tzRule = ref tzRuleBox.Data; TimeZone.ParseTimeZoneBinary(ref tzRule, tzif.Get.AsStream()); @@ -219,7 +217,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone public ResultCode LoadLocationNameList(uint index, out string[] outLocationNameArray, uint maxLength) { - List<string> locationNameList = new List<string>(); + List<string> locationNameList = new(); for (int i = 0; i < LocationNameCache.Length && i < maxLength; i++) { @@ -259,16 +257,16 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone internal ResultCode GetTimeZoneBinary(string locationName, out Stream timeZoneBinaryStream, out LocalStorage ncaFile) { timeZoneBinaryStream = null; - ncaFile = null; + ncaFile = null; if (!HasTimeZoneBinaryTitle() || !IsLocationNameValid(locationName)) { return ResultCode.TimeZoneNotFound; } - ncaFile = new LocalStorage(_virtualFileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open); + ncaFile = new LocalStorage(VirtualFileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open); - Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile); + Nca nca = new(_virtualFileSystem.KeySet, ncaFile); IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _fsIntegrityCheckLevel); using var timeZoneBinaryFile = new UniqueRef<IFile>(); |
