mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
@@ -204,25 +204,30 @@ namespace Wox.Plugin.Program.Programs
|
|||||||
|
|
||||||
private static IEnumerable<string> ProgramPaths(string directory, string[] suffixes)
|
private static IEnumerable<string> ProgramPaths(string directory, string[] suffixes)
|
||||||
{
|
{
|
||||||
if (Directory.Exists(directory))
|
if (!Directory.Exists(directory))
|
||||||
|
return new string[] { };
|
||||||
|
|
||||||
|
var ds = Directory.GetDirectories(directory);
|
||||||
|
|
||||||
|
var paths = ds.SelectMany(d =>
|
||||||
{
|
{
|
||||||
IEnumerable<string> files;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
files = Directory.EnumerateFiles(directory, "*", SearchOption.AllDirectories);
|
var paths_for_suffixes = suffixes.SelectMany(s =>
|
||||||
|
{
|
||||||
|
var pattern = $"*.{s}";
|
||||||
|
var ps = Directory.EnumerateFiles(d, pattern, SearchOption.AllDirectories);
|
||||||
|
return ps;
|
||||||
|
});
|
||||||
|
return paths_for_suffixes;
|
||||||
}
|
}
|
||||||
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
catch (Exception e) when (e is SecurityException || e is UnauthorizedAccessException)
|
||||||
{
|
{
|
||||||
Log.Exception($"|Program.Win32.ProgramPaths|Can't parse directory <{directory}>", e);
|
Log.Exception($"|Program.Win32.ProgramPaths|Don't have permission on <{directory}>", e);
|
||||||
return new string[] { };
|
return new List<string>();
|
||||||
}
|
}
|
||||||
files = files.Where(f => suffixes.Contains(Extension(f)));
|
});
|
||||||
return files;
|
return paths;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return new string[] { };
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string Extension(string path)
|
private static string Extension(string path)
|
||||||
|
|||||||
Reference in New Issue
Block a user