ApplicationLibrary.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. using LibHac;
  2. using LibHac.Common;
  3. using LibHac.Fs;
  4. using LibHac.Fs.Fsa;
  5. using LibHac.FsSystem;
  6. using LibHac.FsSystem.NcaUtils;
  7. using LibHac.Ns;
  8. using Ryujinx.Common.Configuration;
  9. using Ryujinx.Common.Logging;
  10. using Ryujinx.Configuration.System;
  11. using Ryujinx.HLE.FileSystem;
  12. using Ryujinx.HLE.HOS;
  13. using Ryujinx.HLE.HOS.SystemState;
  14. using Ryujinx.HLE.Loaders.Npdm;
  15. using System;
  16. using System.Collections.Generic;
  17. using System.IO;
  18. using System.Reflection;
  19. using System.Text;
  20. using System.Text.Json;
  21. using JsonHelper = Ryujinx.Common.Utilities.JsonHelper;
  22. using Path = System.IO.Path;
  23. namespace Ryujinx.Ui.App
  24. {
  25. public class ApplicationLibrary
  26. {
  27. public event EventHandler<ApplicationAddedEventArgs> ApplicationAdded;
  28. public event EventHandler<ApplicationCountUpdatedEventArgs> ApplicationCountUpdated;
  29. private readonly byte[] _nspIcon;
  30. private readonly byte[] _xciIcon;
  31. private readonly byte[] _ncaIcon;
  32. private readonly byte[] _nroIcon;
  33. private readonly byte[] _nsoIcon;
  34. private VirtualFileSystem _virtualFileSystem;
  35. private Language _desiredTitleLanguage;
  36. public ApplicationLibrary(VirtualFileSystem virtualFileSystem)
  37. {
  38. _virtualFileSystem = virtualFileSystem;
  39. _nspIcon = GetResourceBytes("Ryujinx.Ui.Resources.Icon_NSP.png");
  40. _xciIcon = GetResourceBytes("Ryujinx.Ui.Resources.Icon_XCI.png");
  41. _ncaIcon = GetResourceBytes("Ryujinx.Ui.Resources.Icon_NCA.png");
  42. _nroIcon = GetResourceBytes("Ryujinx.Ui.Resources.Icon_NRO.png");
  43. _nsoIcon = GetResourceBytes("Ryujinx.Ui.Resources.Icon_NSO.png");
  44. }
  45. private byte[] GetResourceBytes(string resourceName)
  46. {
  47. Stream resourceStream = Assembly.GetCallingAssembly().GetManifestResourceStream(resourceName);
  48. byte[] resourceByteArray = new byte[resourceStream.Length];
  49. resourceStream.Read(resourceByteArray);
  50. return resourceByteArray;
  51. }
  52. public IEnumerable<string> GetFilesInDirectory(string directory)
  53. {
  54. Stack<string> stack = new Stack<string>();
  55. stack.Push(directory);
  56. while (stack.Count > 0)
  57. {
  58. string dir = stack.Pop();
  59. string[] content = Array.Empty<string>();
  60. try
  61. {
  62. content = Directory.GetFiles(dir, "*");
  63. }
  64. catch (UnauthorizedAccessException)
  65. {
  66. Logger.Warning?.Print(LogClass.Application, $"Failed to get access to directory: \"{dir}\"");
  67. }
  68. if (content.Length > 0)
  69. {
  70. foreach (string file in content)
  71. {
  72. yield return file;
  73. }
  74. }
  75. try
  76. {
  77. content = Directory.GetDirectories(dir);
  78. }
  79. catch (UnauthorizedAccessException)
  80. {
  81. Logger.Warning?.Print(LogClass.Application, $"Failed to get access to directory: \"{dir}\"");
  82. }
  83. if (content.Length > 0)
  84. {
  85. foreach (string subdir in content)
  86. {
  87. stack.Push(subdir);
  88. }
  89. }
  90. }
  91. }
  92. public void ReadControlData(IFileSystem controlFs, Span<byte> outProperty)
  93. {
  94. using var controlFile = new UniqueRef<IFile>();
  95. controlFs.OpenFile(ref controlFile.Ref(), "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  96. controlFile.Get.Read(out _, 0, outProperty, ReadOption.None).ThrowIfFailure();
  97. }
  98. public void LoadApplications(List<string> appDirs, Language desiredTitleLanguage)
  99. {
  100. int numApplicationsFound = 0;
  101. int numApplicationsLoaded = 0;
  102. _desiredTitleLanguage = desiredTitleLanguage;
  103. // Builds the applications list with paths to found applications
  104. List<string> applications = new List<string>();
  105. foreach (string appDir in appDirs)
  106. {
  107. if (!Directory.Exists(appDir))
  108. {
  109. Logger.Warning?.Print(LogClass.Application, $"The \"game_dirs\" section in \"Config.json\" contains an invalid directory: \"{appDir}\"");
  110. continue;
  111. }
  112. foreach (string app in GetFilesInDirectory(appDir))
  113. {
  114. if ((Path.GetExtension(app).ToLower() == ".nsp") ||
  115. (Path.GetExtension(app).ToLower() == ".pfs0") ||
  116. (Path.GetExtension(app).ToLower() == ".xci") ||
  117. (Path.GetExtension(app).ToLower() == ".nca") ||
  118. (Path.GetExtension(app).ToLower() == ".nro") ||
  119. (Path.GetExtension(app).ToLower() == ".nso"))
  120. {
  121. applications.Add(app);
  122. numApplicationsFound++;
  123. }
  124. }
  125. }
  126. // Loops through applications list, creating a struct and then firing an event containing the struct for each application
  127. foreach (string applicationPath in applications)
  128. {
  129. double fileSize = new FileInfo(applicationPath).Length * 0.000000000931;
  130. string titleName = "Unknown";
  131. string titleId = "0000000000000000";
  132. string developer = "Unknown";
  133. string version = "0";
  134. byte[] applicationIcon = null;
  135. BlitStruct<ApplicationControlProperty> controlHolder = new BlitStruct<ApplicationControlProperty>(1);
  136. try
  137. {
  138. using (FileStream file = new FileStream(applicationPath, FileMode.Open, FileAccess.Read))
  139. {
  140. if ((Path.GetExtension(applicationPath).ToLower() == ".nsp") ||
  141. (Path.GetExtension(applicationPath).ToLower() == ".pfs0") ||
  142. (Path.GetExtension(applicationPath).ToLower() == ".xci"))
  143. {
  144. try
  145. {
  146. PartitionFileSystem pfs;
  147. bool isExeFs = false;
  148. if (Path.GetExtension(applicationPath).ToLower() == ".xci")
  149. {
  150. Xci xci = new Xci(_virtualFileSystem.KeySet, file.AsStorage());
  151. pfs = xci.OpenPartition(XciPartitionType.Secure);
  152. }
  153. else
  154. {
  155. pfs = new PartitionFileSystem(file.AsStorage());
  156. // If the NSP doesn't have a main NCA, decrement the number of applications found and then continue to the next application.
  157. bool hasMainNca = false;
  158. foreach (DirectoryEntryEx fileEntry in pfs.EnumerateEntries("/", "*"))
  159. {
  160. if (Path.GetExtension(fileEntry.FullPath).ToLower() == ".nca")
  161. {
  162. using var ncaFile = new UniqueRef<IFile>();
  163. pfs.OpenFile(ref ncaFile.Ref(), fileEntry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
  164. Nca nca = new Nca(_virtualFileSystem.KeySet, ncaFile.Get.AsStorage());
  165. int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
  166. // Some main NCAs don't have a data partition, so check if the partition exists before opening it
  167. if (nca.Header.ContentType == NcaContentType.Program && !(nca.SectionExists(NcaSectionType.Data) && nca.Header.GetFsHeader(dataIndex).IsPatchSection()))
  168. {
  169. hasMainNca = true;
  170. break;
  171. }
  172. }
  173. else if (Path.GetFileNameWithoutExtension(fileEntry.FullPath) == "main")
  174. {
  175. isExeFs = true;
  176. }
  177. }
  178. if (!hasMainNca && !isExeFs)
  179. {
  180. numApplicationsFound--;
  181. continue;
  182. }
  183. }
  184. if (isExeFs)
  185. {
  186. applicationIcon = _nspIcon;
  187. using var npdmFile = new UniqueRef<IFile>();
  188. Result result = pfs.OpenFile(ref npdmFile.Ref(), "/main.npdm".ToU8Span(), OpenMode.Read);
  189. if (ResultFs.PathNotFound.Includes(result))
  190. {
  191. Npdm npdm = new Npdm(npdmFile.Get.AsStream());
  192. titleName = npdm.TitleName;
  193. titleId = npdm.Aci0.TitleId.ToString("x16");
  194. }
  195. }
  196. else
  197. {
  198. // Store the ControlFS in variable called controlFs
  199. GetControlFsAndTitleId(pfs, out IFileSystem controlFs, out titleId);
  200. ReadControlData(controlFs, controlHolder.ByteSpan);
  201. // Get the title name, title ID, developer name and version number from the NACP
  202. version = IsUpdateApplied(titleId, out string updateVersion) ? updateVersion : controlHolder.Value.DisplayVersion.ToString();
  203. GetNameIdDeveloper(ref controlHolder.Value, out titleName, out _, out developer);
  204. // Read the icon from the ControlFS and store it as a byte array
  205. try
  206. {
  207. using var icon = new UniqueRef<IFile>();
  208. controlFs.OpenFile(ref icon.Ref(), $"/icon_{_desiredTitleLanguage}.dat".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  209. using (MemoryStream stream = new MemoryStream())
  210. {
  211. icon.Get.AsStream().CopyTo(stream);
  212. applicationIcon = stream.ToArray();
  213. }
  214. }
  215. catch (HorizonResultException)
  216. {
  217. foreach (DirectoryEntryEx entry in controlFs.EnumerateEntries("/", "*"))
  218. {
  219. if (entry.Name == "control.nacp")
  220. {
  221. continue;
  222. }
  223. using var icon = new UniqueRef<IFile>();
  224. controlFs.OpenFile(ref icon.Ref(), entry.FullPath.ToU8Span(), OpenMode.Read).ThrowIfFailure();
  225. using (MemoryStream stream = new MemoryStream())
  226. {
  227. icon.Get.AsStream().CopyTo(stream);
  228. applicationIcon = stream.ToArray();
  229. }
  230. if (applicationIcon != null)
  231. {
  232. break;
  233. }
  234. }
  235. if (applicationIcon == null)
  236. {
  237. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  238. }
  239. }
  240. }
  241. }
  242. catch (MissingKeyException exception)
  243. {
  244. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  245. Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
  246. }
  247. catch (InvalidDataException)
  248. {
  249. applicationIcon = Path.GetExtension(applicationPath).ToLower() == ".xci" ? _xciIcon : _nspIcon;
  250. Logger.Warning?.Print(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {applicationPath}");
  251. }
  252. catch (Exception exception)
  253. {
  254. Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{applicationPath}' Error: {exception}");
  255. numApplicationsFound--;
  256. continue;
  257. }
  258. }
  259. else if (Path.GetExtension(applicationPath).ToLower() == ".nro")
  260. {
  261. BinaryReader reader = new BinaryReader(file);
  262. byte[] Read(long position, int size)
  263. {
  264. file.Seek(position, SeekOrigin.Begin);
  265. return reader.ReadBytes(size);
  266. }
  267. try
  268. {
  269. file.Seek(24, SeekOrigin.Begin);
  270. int assetOffset = reader.ReadInt32();
  271. if (Encoding.ASCII.GetString(Read(assetOffset, 4)) == "ASET")
  272. {
  273. byte[] iconSectionInfo = Read(assetOffset + 8, 0x10);
  274. long iconOffset = BitConverter.ToInt64(iconSectionInfo, 0);
  275. long iconSize = BitConverter.ToInt64(iconSectionInfo, 8);
  276. ulong nacpOffset = reader.ReadUInt64();
  277. ulong nacpSize = reader.ReadUInt64();
  278. // Reads and stores game icon as byte array
  279. applicationIcon = Read(assetOffset + iconOffset, (int) iconSize);
  280. // Read the NACP data
  281. Read(assetOffset + (int)nacpOffset, (int)nacpSize).AsSpan().CopyTo(controlHolder.ByteSpan);
  282. // Get the title name, title ID, developer name and version number from the NACP
  283. version = controlHolder.Value.DisplayVersion.ToString();
  284. GetNameIdDeveloper(ref controlHolder.Value, out titleName, out titleId, out developer);
  285. }
  286. else
  287. {
  288. applicationIcon = _nroIcon;
  289. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  290. }
  291. }
  292. catch
  293. {
  294. Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
  295. numApplicationsFound--;
  296. continue;
  297. }
  298. }
  299. else if (Path.GetExtension(applicationPath).ToLower() == ".nca")
  300. {
  301. try
  302. {
  303. Nca nca = new Nca(_virtualFileSystem.KeySet, new FileStream(applicationPath, FileMode.Open, FileAccess.Read).AsStorage());
  304. int dataIndex = Nca.GetSectionIndexFromType(NcaSectionType.Data, NcaContentType.Program);
  305. if (nca.Header.ContentType != NcaContentType.Program || (nca.SectionExists(NcaSectionType.Data) && nca.Header.GetFsHeader(dataIndex).IsPatchSection()))
  306. {
  307. numApplicationsFound--;
  308. continue;
  309. }
  310. }
  311. catch (InvalidDataException)
  312. {
  313. Logger.Warning?.Print(LogClass.Application, $"The NCA header content type check has failed. This is usually because the header key is incorrect or missing. Errored File: {applicationPath}");
  314. }
  315. catch
  316. {
  317. Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
  318. numApplicationsFound--;
  319. continue;
  320. }
  321. applicationIcon = _ncaIcon;
  322. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  323. }
  324. // If its an NSO we just set defaults
  325. else if (Path.GetExtension(applicationPath).ToLower() == ".nso")
  326. {
  327. applicationIcon = _nsoIcon;
  328. titleName = Path.GetFileNameWithoutExtension(applicationPath);
  329. }
  330. }
  331. }
  332. catch (IOException exception)
  333. {
  334. Logger.Warning?.Print(LogClass.Application, exception.Message);
  335. numApplicationsFound--;
  336. continue;
  337. }
  338. ApplicationMetadata appMetadata = LoadAndSaveMetaData(titleId);
  339. if (appMetadata.LastPlayed != "Never" && !DateTime.TryParse(appMetadata.LastPlayed, out _))
  340. {
  341. Logger.Warning?.Print(LogClass.Application, $"Last played datetime \"{appMetadata.LastPlayed}\" is invalid for current system culture, skipping (did current culture change?)");
  342. appMetadata.LastPlayed = "Never";
  343. }
  344. ApplicationData data = new ApplicationData
  345. {
  346. Favorite = appMetadata.Favorite,
  347. Icon = applicationIcon,
  348. TitleName = titleName,
  349. TitleId = titleId,
  350. Developer = developer,
  351. Version = version,
  352. TimePlayed = ConvertSecondsToReadableString(appMetadata.TimePlayed),
  353. LastPlayed = appMetadata.LastPlayed,
  354. FileExtension = Path.GetExtension(applicationPath).ToUpper().Remove(0, 1),
  355. FileSize = (fileSize < 1) ? (fileSize * 1024).ToString("0.##") + "MB" : fileSize.ToString("0.##") + "GB",
  356. Path = applicationPath,
  357. ControlHolder = controlHolder
  358. };
  359. numApplicationsLoaded++;
  360. OnApplicationAdded(new ApplicationAddedEventArgs()
  361. {
  362. AppData = data
  363. });
  364. OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
  365. {
  366. NumAppsFound = numApplicationsFound,
  367. NumAppsLoaded = numApplicationsLoaded
  368. });
  369. }
  370. OnApplicationCountUpdated(new ApplicationCountUpdatedEventArgs()
  371. {
  372. NumAppsFound = numApplicationsFound,
  373. NumAppsLoaded = numApplicationsLoaded
  374. });
  375. }
  376. protected void OnApplicationAdded(ApplicationAddedEventArgs e)
  377. {
  378. ApplicationAdded?.Invoke(null, e);
  379. }
  380. protected void OnApplicationCountUpdated(ApplicationCountUpdatedEventArgs e)
  381. {
  382. ApplicationCountUpdated?.Invoke(null, e);
  383. }
  384. private void GetControlFsAndTitleId(PartitionFileSystem pfs, out IFileSystem controlFs, out string titleId)
  385. {
  386. (_, _, Nca controlNca) = ApplicationLoader.GetGameData(_virtualFileSystem, pfs, 0);
  387. // Return the ControlFS
  388. controlFs = controlNca?.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None);
  389. titleId = controlNca?.Header.TitleId.ToString("x16");
  390. }
  391. internal ApplicationMetadata LoadAndSaveMetaData(string titleId, Action<ApplicationMetadata> modifyFunction = null)
  392. {
  393. string metadataFolder = Path.Combine(AppDataManager.GamesDirPath, titleId, "gui");
  394. string metadataFile = Path.Combine(metadataFolder, "metadata.json");
  395. ApplicationMetadata appMetadata;
  396. if (!File.Exists(metadataFile))
  397. {
  398. Directory.CreateDirectory(metadataFolder);
  399. appMetadata = new ApplicationMetadata();
  400. using (FileStream stream = File.Create(metadataFile, 4096, FileOptions.WriteThrough))
  401. {
  402. JsonHelper.Serialize(stream, appMetadata, true);
  403. }
  404. }
  405. try
  406. {
  407. appMetadata = JsonHelper.DeserializeFromFile<ApplicationMetadata>(metadataFile);
  408. }
  409. catch (JsonException)
  410. {
  411. Logger.Warning?.Print(LogClass.Application, $"Failed to parse metadata json for {titleId}. Loading defaults.");
  412. appMetadata = new ApplicationMetadata();
  413. }
  414. if (modifyFunction != null)
  415. {
  416. modifyFunction(appMetadata);
  417. using (FileStream stream = File.Create(metadataFile, 4096, FileOptions.WriteThrough))
  418. {
  419. JsonHelper.Serialize(stream, appMetadata, true);
  420. }
  421. }
  422. return appMetadata;
  423. }
  424. private string ConvertSecondsToReadableString(double seconds)
  425. {
  426. const int secondsPerMinute = 60;
  427. const int secondsPerHour = secondsPerMinute * 60;
  428. const int secondsPerDay = secondsPerHour * 24;
  429. string readableString;
  430. if (seconds < secondsPerMinute)
  431. {
  432. readableString = $"{seconds}s";
  433. }
  434. else if (seconds < secondsPerHour)
  435. {
  436. readableString = $"{Math.Round(seconds / secondsPerMinute, 2, MidpointRounding.AwayFromZero)} mins";
  437. }
  438. else if (seconds < secondsPerDay)
  439. {
  440. readableString = $"{Math.Round(seconds / secondsPerHour, 2, MidpointRounding.AwayFromZero)} hrs";
  441. }
  442. else
  443. {
  444. readableString = $"{Math.Round(seconds / secondsPerDay, 2, MidpointRounding.AwayFromZero)} days";
  445. }
  446. return readableString;
  447. }
  448. private void GetNameIdDeveloper(ref ApplicationControlProperty controlData, out string titleName, out string titleId, out string publisher)
  449. {
  450. _ = Enum.TryParse(_desiredTitleLanguage.ToString(), out TitleLanguage desiredTitleLanguage);
  451. if (controlData.Titles.Length > (int)desiredTitleLanguage)
  452. {
  453. titleName = controlData.Titles[(int)desiredTitleLanguage].Name.ToString();
  454. publisher = controlData.Titles[(int)desiredTitleLanguage].Publisher.ToString();
  455. }
  456. else
  457. {
  458. titleName = null;
  459. publisher = null;
  460. }
  461. if (string.IsNullOrWhiteSpace(titleName))
  462. {
  463. foreach (ApplicationControlTitle controlTitle in controlData.Titles)
  464. {
  465. if (!((U8Span)controlTitle.Name).IsEmpty())
  466. {
  467. titleName = controlTitle.Name.ToString();
  468. break;
  469. }
  470. }
  471. }
  472. if (string.IsNullOrWhiteSpace(publisher))
  473. {
  474. foreach (ApplicationControlTitle controlTitle in controlData.Titles)
  475. {
  476. if (!((U8Span)controlTitle.Publisher).IsEmpty())
  477. {
  478. publisher = controlTitle.Publisher.ToString();
  479. break;
  480. }
  481. }
  482. }
  483. if (controlData.PresenceGroupId != 0)
  484. {
  485. titleId = controlData.PresenceGroupId.ToString("x16");
  486. }
  487. else if (controlData.SaveDataOwnerId.Value != 0)
  488. {
  489. titleId = controlData.SaveDataOwnerId.ToString();
  490. }
  491. else if (controlData.AddOnContentBaseId != 0)
  492. {
  493. titleId = (controlData.AddOnContentBaseId - 0x1000).ToString("x16");
  494. }
  495. else
  496. {
  497. titleId = "0000000000000000";
  498. }
  499. }
  500. private bool IsUpdateApplied(string titleId, out string version)
  501. {
  502. string updatePath = "(unknown)";
  503. try
  504. {
  505. (Nca patchNca, Nca controlNca) = ApplicationLoader.GetGameUpdateData(_virtualFileSystem, titleId, 0, out updatePath);
  506. if (patchNca != null && controlNca != null)
  507. {
  508. ApplicationControlProperty controlData = new ApplicationControlProperty();
  509. using var nacpFile = new UniqueRef<IFile>();
  510. controlNca.OpenFileSystem(NcaSectionType.Data, IntegrityCheckLevel.None).OpenFile(ref nacpFile.Ref(), "/control.nacp".ToU8Span(), OpenMode.Read).ThrowIfFailure();
  511. nacpFile.Get.Read(out _, 0, SpanHelpers.AsByteSpan(ref controlData), ReadOption.None).ThrowIfFailure();
  512. version = controlData.DisplayVersion.ToString();
  513. return true;
  514. }
  515. }
  516. catch (InvalidDataException)
  517. {
  518. Logger.Warning?.Print(LogClass.Application,
  519. $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {updatePath}");
  520. }
  521. catch (MissingKeyException exception)
  522. {
  523. Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}. Errored File: {updatePath}");
  524. }
  525. version = "";
  526. return false;
  527. }
  528. }
  529. }