Don't load files from hidden subdirectories

This commit is contained in:
TSR Berry 2024-08-02 00:04:02 +02:00
commit f9e99b4ebe
No known key found for this signature in database
GPG key ID: 52353C0A4CCA15E2

View file

@ -502,7 +502,13 @@ namespace Ryujinx.UI.App.Common
try try
{ {
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", SearchOption.AllDirectories).Where(file => EnumerationOptions options = new()
{
RecurseSubdirectories = true,
IgnoreInaccessible = false,
};
IEnumerable<string> files = Directory.EnumerateFiles(appDir, "*", options).Where(file =>
{ {
return return
(Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value) || (Path.GetExtension(file).ToLower() is ".nsp" && ConfigurationState.Instance.UI.ShownFileTypes.NSP.Value) ||
@ -521,16 +527,12 @@ namespace Ryujinx.UI.App.Common
} }
var fileInfo = new FileInfo(app); var fileInfo = new FileInfo(app);
string extension = fileInfo.Extension.ToLower();
if (!fileInfo.Attributes.HasFlag(FileAttributes.Hidden) && extension is ".nsp" or ".pfs0" or ".xci" or ".nca" or ".nro" or ".nso")
{
var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName; var fullPath = fileInfo.ResolveLinkTarget(true)?.FullName ?? fileInfo.FullName;
applicationPaths.Add(fullPath); applicationPaths.Add(fullPath);
numApplicationsFound++; numApplicationsFound++;
} }
} }
}
catch (UnauthorizedAccessException) catch (UnauthorizedAccessException)
{ {
Logger.Warning?.Print(LogClass.Application, $"Failed to get access to directory: \"{appDir}\""); Logger.Warning?.Print(LogClass.Application, $"Failed to get access to directory: \"{appDir}\"");