@@ -25,23 +25,29 @@ public class Win32 : IProgram, IEquatable<Win32>
25
25
public string Name { get ; set ; }
26
26
public string UniqueIdentifier { get => _uid ; set => _uid = value == null ? string . Empty : value . ToLowerInvariant ( ) ; } // For path comparison
27
27
public string IcoPath { get ; set ; }
28
+
28
29
/// <summary>
29
30
/// Path of the file. It's the path of .lnk and .url for .lnk and .url files.
30
31
/// </summary>
31
32
public string FullPath { get ; set ; }
33
+
32
34
/// <summary>
33
35
/// Path of the executable for .lnk, or the URL for .url. Arguments are included if any.
34
36
/// </summary>
35
37
public string LnkResolvedPath { get ; set ; }
38
+
36
39
/// <summary>
37
40
/// Path of the actual executable file. Args are included.
38
41
/// </summary>
39
42
public string ExecutablePath => LnkResolvedPath ?? FullPath ;
43
+
40
44
public string ParentDirectory { get ; set ; }
45
+
41
46
/// <summary>
42
47
/// Name of the executable for .lnk files
43
48
/// </summary>
44
49
public string ExecutableName { get ; set ; }
50
+
45
51
public string Description { get ; set ; }
46
52
public bool Valid { get ; set ; }
47
53
public bool Enabled { get ; set ; }
@@ -199,9 +205,7 @@ public List<Result> ContextMenus(IPublicAPI api)
199
205
{
200
206
var info = new ProcessStartInfo
201
207
{
202
- FileName = FullPath ,
203
- WorkingDirectory = ParentDirectory ,
204
- UseShellExecute = true
208
+ FileName = FullPath , WorkingDirectory = ParentDirectory , UseShellExecute = true
205
209
} ;
206
210
207
211
Task . Run ( ( ) => Main . StartProcess ( ShellCommand . RunAsDifferentUser , info ) ) ;
@@ -363,6 +367,7 @@ private static Win32 UrlProgram(string path, string[] protocols)
363
367
{
364
368
return program ;
365
369
}
370
+
366
371
foreach ( var protocol in protocols )
367
372
{
368
373
if ( url . StartsWith ( protocol ) )
@@ -418,10 +423,12 @@ private static IEnumerable<string> EnumerateProgramsInDir(string directory, stri
418
423
if ( ! Directory . Exists ( directory ) )
419
424
return Enumerable . Empty < string > ( ) ;
420
425
421
- return Directory . EnumerateFiles ( directory , "*" , new EnumerationOptions
422
- {
423
- IgnoreInaccessible = true , RecurseSubdirectories = recursive
424
- } ) . Where ( x => suffixes . Contains ( Extension ( x ) ) ) ;
426
+ return Directory
427
+ . EnumerateFiles (
428
+ directory ,
429
+ "*" ,
430
+ new EnumerationOptions { IgnoreInaccessible = true , RecurseSubdirectories = recursive } )
431
+ . Where ( x => suffixes . Contains ( Extension ( x ) ) ) ;
425
432
}
426
433
427
434
private static string Extension ( string path )
@@ -471,7 +478,7 @@ private static IEnumerable<Win32> PATHPrograms(string[] suffixes, string[] proto
471
478
}
472
479
473
480
var paths = pathEnv . Split ( ";" , StringSplitOptions . RemoveEmptyEntries ) . DistinctBy ( p => p . ToLowerInvariant ( ) ) ;
474
-
481
+
475
482
var toFilter = paths . Where ( x => commonParents . All ( parent => ! FilesFolders . PathContains ( parent , x ) ) )
476
483
. AsParallel ( )
477
484
. SelectMany ( p => EnumerateProgramsInDir ( p , suffixes , recursive : false ) ) ;
0 commit comments