private IEnumerable <DriveJunkNode> GetUninstallerJunk()
        {
            if (!File.Exists(Uninstaller.UninstallerFullFilename))
            {
                return(Enumerable.Empty <DriveJunkNode>());
            }

            DriveJunkNode result;

            switch (Uninstaller.UninstallerKind)
            {
            case UninstallerType.InstallShield:
                var target = Path.GetDirectoryName(Uninstaller.UninstallerFullFilename);
                result = new DriveDirectoryJunkNode(Path.GetDirectoryName(target),
                                                    Path.GetFileName(target), Uninstaller.DisplayName);
                break;

            case UninstallerType.InnoSetup:
            case UninstallerType.Msiexec:
            case UninstallerType.Nsis:
                result = new DriveFileJunkNode(Path.GetDirectoryName(Uninstaller.UninstallerFullFilename),
                                               Path.GetFileName(Uninstaller.UninstallerFullFilename), Uninstaller.DisplayName);
                break;

            default:
                return(Enumerable.Empty <DriveJunkNode>());
            }

            result.Confidence.Add(ConfidencePart.ExplicitConnection);

            return(new[] { result });
        }
Example #2
0
        public override IEnumerable <JunkNode> FindJunk()
        {
            var results = new List <JunkNode>();

            var installLocationIsSafe = !OtherUninstallers.Any(
                x => PathTools.PathsEqual(x.InstallLocation, Uninstaller.InstallLocation));
            var uninstallerLocationIsSafe = !OtherUninstallers.Any(
                x => PathTools.PathsEqual(x.UninstallerLocation, Uninstaller.UninstallerLocation));

            var addAction = new Action <bool, Shortcut>((isSafe, source) =>
            {
                var driveJunkNode = new DriveFileJunkNode(Path.GetDirectoryName(source.LinkFilename),
                                                          Path.GetFileName(source.LinkFilename), Uninstaller.DisplayName);

                driveJunkNode.Confidence.Add(ConfidencePart.ExplicitConnection);
                if (!isSafe)
                {
                    driveJunkNode.Confidence.Add(ConfidencePart.DirectoryStillUsed);
                }

                results.Add(driveJunkNode);
                // Remove from the shortcut list so other uninstallers won't show up with it
                //_links.Remove(source);
            });

            foreach (var source in _links.ToList())
            {
                if (CheckMatch(source.LinkTarget, Uninstaller.InstallLocation))
                {
                    addAction(installLocationIsSafe, source);
                }
                else if (CheckMatch(source.LinkTarget, Uninstaller.UninstallerLocation))
                {
                    addAction(uninstallerLocationIsSafe, source);
                }
            }

            return(results);
        }