Make sure TryGetApplicationsFromFile() doesn't throw exceptions anymore
This commit is contained in:
parent
93f4de7219
commit
c00e4bdebb
1 changed files with 125 additions and 147 deletions
|
@ -86,8 +86,6 @@ namespace Ryujinx.UI.App.Common
|
||||||
|
|
||||||
using UniqueRef<IFile> npdmFile = new();
|
using UniqueRef<IFile> npdmFile = new();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Result result = pfs.OpenFile(ref npdmFile.Ref, "/main.npdm".ToU8Span(), OpenMode.Read);
|
Result result = pfs.OpenFile(ref npdmFile.Ref, "/main.npdm".ToU8Span(), OpenMode.Read);
|
||||||
|
|
||||||
if (ResultFs.PathNotFound.Includes(result))
|
if (ResultFs.PathNotFound.Includes(result))
|
||||||
|
@ -100,15 +98,10 @@ namespace Ryujinx.UI.App.Common
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception.Message}");
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <exception cref="MissingKeyException">The configured key set is missing a key.</exception>
|
/// <exception cref="MissingKeyException">The configured key set is missing a key.</exception>
|
||||||
|
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
|
||||||
|
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
|
||||||
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
||||||
/// <exception cref="Ryujinx.HLE.Exceptions.InvalidNpdmException">The npdm file doesn't contain valid data.</exception>
|
/// <exception cref="Ryujinx.HLE.Exceptions.InvalidNpdmException">The npdm file doesn't contain valid data.</exception>
|
||||||
/// <exception cref="NotImplementedException">The FsAccessHeader.ContentOwnerId section is not implemented.</exception>
|
/// <exception cref="NotImplementedException">The FsAccessHeader.ContentOwnerId section is not implemented.</exception>
|
||||||
|
@ -182,13 +175,15 @@ namespace Ryujinx.UI.App.Common
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <exception cref="MissingKeyException">The configured key set is missing a key.</exception>
|
||||||
|
/// <exception cref="InvalidDataException">The NCA header could not be decrypted.</exception>
|
||||||
|
/// <exception cref="NotSupportedException">The NCA version is not supported.</exception>
|
||||||
|
/// <exception cref="HorizonResultException">An error occured while reading PFS data.</exception>
|
||||||
private List<ApplicationData> GetApplicationsFromPfs(IFileSystem pfs, string filePath)
|
private List<ApplicationData> GetApplicationsFromPfs(IFileSystem pfs, string filePath)
|
||||||
{
|
{
|
||||||
var applications = new List<ApplicationData>();
|
var applications = new List<ApplicationData>();
|
||||||
string extension = Path.GetExtension(filePath).ToLower();
|
string extension = Path.GetExtension(filePath).ToLower();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel))
|
foreach ((ulong titleId, ContentMetaData content) in pfs.GetContentData(ContentMetaType.Application, _virtualFileSystem, _checkLevel))
|
||||||
{
|
{
|
||||||
ApplicationData applicationData = new()
|
ApplicationData applicationData = new()
|
||||||
|
@ -263,19 +258,6 @@ namespace Ryujinx.UI.App.Common
|
||||||
|
|
||||||
applications.Add(applicationData);
|
applications.Add(applicationData);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (MissingKeyException exception)
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
|
|
||||||
}
|
|
||||||
catch (InvalidDataException)
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"The header key is incorrect or missing and therefore the NCA header content type check has failed. Errored File: {filePath}");
|
|
||||||
}
|
|
||||||
catch (Exception exception)
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{filePath}' Error: {exception}");
|
|
||||||
}
|
|
||||||
|
|
||||||
return applications;
|
return applications;
|
||||||
}
|
}
|
||||||
|
@ -331,8 +313,6 @@ namespace Ryujinx.UI.App.Common
|
||||||
BinaryReader reader = new(file);
|
BinaryReader reader = new(file);
|
||||||
ApplicationData application = new();
|
ApplicationData application = new();
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
file.Seek(24, SeekOrigin.Begin);
|
file.Seek(24, SeekOrigin.Begin);
|
||||||
|
|
||||||
int assetOffset = reader.ReadInt32();
|
int assetOffset = reader.ReadInt32();
|
||||||
|
@ -370,13 +350,6 @@ namespace Ryujinx.UI.App.Common
|
||||||
|
|
||||||
application.ControlHolder = controlHolder;
|
application.ControlHolder = controlHolder;
|
||||||
applications.Add(application);
|
applications.Add(application);
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -388,8 +361,6 @@ namespace Ryujinx.UI.App.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case ".nca":
|
case ".nca":
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
ApplicationData application = new();
|
ApplicationData application = new();
|
||||||
|
|
||||||
|
@ -405,17 +376,6 @@ namespace Ryujinx.UI.App.Common
|
||||||
application.ControlHolder = controlHolder;
|
application.ControlHolder = controlHolder;
|
||||||
|
|
||||||
applications.Add(application);
|
applications.Add(application);
|
||||||
}
|
|
||||||
catch (InvalidDataException)
|
|
||||||
{
|
|
||||||
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}");
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. Errored File: {applicationPath}");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -434,12 +394,30 @@ namespace Ryujinx.UI.App.Common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (MissingKeyException exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"Your key set is missing a key with the name: {exception.Name}");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (InvalidDataException)
|
||||||
|
{
|
||||||
|
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}");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
catch (IOException exception)
|
catch (IOException exception)
|
||||||
{
|
{
|
||||||
Logger.Warning?.Print(LogClass.Application, exception.Message);
|
Logger.Warning?.Print(LogClass.Application, exception.Message);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
catch (Exception exception)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"The file encountered was not of a valid type. File: '{applicationPath}' Error: {exception}");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var data in applications)
|
foreach (var data in applications)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue