ApplicationLibrary.cs 28 KB

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