Filter hidden game files from the Game List (#4051)
* Filter “._” files from the game list * Filter all hidden files from the game list * Fix style Co-authored-by: gdkchan <gab.dark.100@gmail.com> * merge OR expression into a pattern * migrate from GetFiles/Directories to Enumerate * Remove GetFilesInDirectory() * Update Ryujinx.Ui.Common/App/ApplicationLibrary.cs Co-authored-by: Ac_K <Acoustik666@gmail.com> * add error handeling * code cleanup Co-authored-by: gdkchan <gab.dark.100@gmail.com> Co-authored-by: Ac_K <Acoustik666@gmail.com>
This commit is contained in:
parent
9dfe81770a
commit
2b23463daa
@ -68,53 +68,6 @@ namespace Ryujinx.Ui.App.Common
|
|||||||
_cancellationToken?.Cancel();
|
_cancellationToken?.Cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<string> GetFilesInDirectory(string directory)
|
|
||||||
{
|
|
||||||
Stack<string> stack = new Stack<string>();
|
|
||||||
|
|
||||||
stack.Push(directory);
|
|
||||||
|
|
||||||
while (stack.Count > 0)
|
|
||||||
{
|
|
||||||
string dir = stack.Pop();
|
|
||||||
string[] content = Array.Empty<string>();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
content = Directory.GetFiles(dir, "*");
|
|
||||||
}
|
|
||||||
catch (UnauthorizedAccessException)
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"Failed to get access to directory: \"{dir}\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content.Length > 0)
|
|
||||||
{
|
|
||||||
foreach (string file in content)
|
|
||||||
{
|
|
||||||
yield return file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
content = Directory.GetDirectories(dir);
|
|
||||||
}
|
|
||||||
catch (UnauthorizedAccessException)
|
|
||||||
{
|
|
||||||
Logger.Warning?.Print(LogClass.Application, $"Failed to get access to directory: \"{dir}\"");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content.Length > 0)
|
|
||||||
{
|
|
||||||
foreach (string subdir in content)
|
|
||||||
{
|
|
||||||
stack.Push(subdir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadControlData(IFileSystem controlFs, Span<byte> outProperty)
|
public void ReadControlData(IFileSystem controlFs, Span<byte> outProperty)
|
||||||
{
|
{
|
||||||
using var controlFile = new UniqueRef<IFile>();
|
using var controlFile = new UniqueRef<IFile>();
|
||||||
@ -151,26 +104,28 @@ namespace Ryujinx.Ui.App.Common
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (string app in GetFilesInDirectory(appDir))
|
try
|
||||||
{
|
{
|
||||||
if (_cancellationToken.Token.IsCancellationRequested)
|
foreach (string app in Directory.EnumerateFiles(appDir, "*", SearchOption.AllDirectories))
|
||||||
{
|
{
|
||||||
return;
|
if (_cancellationToken.Token.IsCancellationRequested)
|
||||||
}
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string extension = Path.GetExtension(app).ToLower();
|
string extension = Path.GetExtension(app).ToLower();
|
||||||
|
|
||||||
if ((extension == ".nsp") ||
|
if (!File.GetAttributes(app).HasFlag(FileAttributes.Hidden) && extension is ".nsp" or ".pfs0" or ".xci" or ".nca" or ".nro" or ".nso")
|
||||||
(extension == ".pfs0") ||
|
{
|
||||||
(extension == ".xci") ||
|
applications.Add(app);
|
||||||
(extension == ".nca") ||
|
numApplicationsFound++;
|
||||||
(extension == ".nro") ||
|
}
|
||||||
(extension == ".nso"))
|
|
||||||
{
|
|
||||||
applications.Add(app);
|
|
||||||
numApplicationsFound++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
Logger.Warning?.Print(LogClass.Application, $"Failed to get access to directory: \"{appDir}\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loops through applications list, creating a struct and then firing an event containing the struct for each application
|
// Loops through applications list, creating a struct and then firing an event containing the struct for each application
|
||||||
|
Loading…
Reference in New Issue
Block a user