Skip to content

Commit

Permalink
Tweak search rules in subdirectories to find more unregistered apps
Browse files Browse the repository at this point in the history
Closes #358
  • Loading branch information
Klocman committed May 9, 2022
1 parent 54f6973 commit fa0097f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions source/UninstallTools/Factory/InfoAdders/AppExecutablesSearcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ public void AddMissingInformation(ApplicationUninstallerEntry target)
internal static ScanDirectoryResult ScanDirectory(DirectoryInfo directory)
{
var results = new List<FileInfo>(directory.GetFiles("*.exe", SearchOption.TopDirectoryOnly));
var otherSubdirs = new List<DirectoryInfo>();
var binSubdirs = new List<DirectoryInfo>();
var otherSubdirs = new List<DirectoryInfo>();
var maybeSubdirs = new List<DirectoryInfo>();
foreach (var subdir in directory.GetDirectories())
{
try
Expand All @@ -92,11 +93,14 @@ internal static ScanDirectoryResult ScanDirectory(DirectoryInfo directory)
}
else
{
// This skips ISO language codes, much faster than a more specific compare
if (subName.Length == 5 && subName[2].Equals('-')) continue;

// Directories with very short names likely contain program files
if (subName.Length > 3 &&
// This skips ISO language codes, much faster than a more specific compare
(subName.Length != 5 || !subName[2].Equals('-')))
if (subName.Length > 3)
otherSubdirs.Add(subdir);
else
maybeSubdirs.Add(subdir);
}
}
catch (IOException)
Expand All @@ -107,6 +111,9 @@ internal static ScanDirectoryResult ScanDirectory(DirectoryInfo directory)
}
}

if (results.Count == 0 && binSubdirs.Count == 0)
otherSubdirs.AddRange(maybeSubdirs);

return new ScanDirectoryResult(results, binSubdirs, otherSubdirs);
}

Expand Down

0 comments on commit fa0097f

Please sign in to comment.