Exemplo n.º 1
0
        /// <summary>
        /// Find and kill a diff tool process.
        /// </summary>
        public static void Kill(string tempFile, string targetFile)
        {
            if (Disabled)
            {
                return;
            }

            var extension = Extensions.GetExtension(tempFile);

            if (!DiffTools.TryFind(extension, out var diffTool))
            {
                Logging.Write($"Extension not found. {extension}");
                return;
            }

            var command = diffTool.BuildCommand(tempFile, targetFile);

            if (diffTool.IsMdi)
            {
                Logging.Write($"DiffTool is Mdi so not killing. diffTool: {diffTool.ExePath}");
                return;
            }

            ProcessCleanup.Kill(command);
        }
Exemplo n.º 2
0
        public static Task <LaunchResult> LaunchAsync(DiffTool tool, string tempFile, string targetFile)
        {
            GuardFiles(tempFile, targetFile);

            return(InnerLaunchAsync(
                       (out ResolvedTool? resolved) => DiffTools.TryFind(tool, out resolved),
                       tempFile,
                       targetFile));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Launch a diff tool for the given paths.
        /// </summary>
        public static Task <LaunchResult> LaunchAsync(string tempFile, string targetFile)
        {
            GuardFiles(tempFile, targetFile);

            return(InnerLaunchAsync(
                       (out ResolvedTool? tool) =>
            {
                var extension = Extensions.GetExtension(tempFile);
                return DiffTools.TryFind(extension, out tool);
            },
                       tempFile,
                       targetFile));
        }
Exemplo n.º 4
0
        public static Task <LaunchResult> Launch(DiffTool tool, string tempFile, string targetFile)
        {
            GuardFiles(tempFile, targetFile);

            if (Disabled)
            {
                return(Task.FromResult(LaunchResult.Disabled));
            }

            if (!DiffTools.TryFind(tool, out var resolvedTool))
            {
                return(Task.FromResult(LaunchResult.NoDiffToolFound));
            }

            return(Launch(resolvedTool, tempFile, targetFile));
        }
Exemplo n.º 5
0
        /// <summary>
        /// Launch a diff tool for the given paths.
        /// </summary>
        public static Task <LaunchResult> Launch(string tempFile, string targetFile)
        {
            GuardFiles(tempFile, targetFile);
            if (Disabled)
            {
                return(Task.FromResult(LaunchResult.Disabled));
            }

            var extension = Extensions.GetExtension(tempFile);

            if (!DiffTools.TryFind(extension, out var diffTool))
            {
                return(Task.FromResult(LaunchResult.NoDiffToolFound));
            }

            return(Launch(diffTool, tempFile, targetFile));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Find and kill a diff tool process.
        /// </summary>
        public static void Kill(string path1, string path2)
        {
            Guard.AgainstNullOrEmpty(path1, nameof(path1));
            Guard.AgainstNullOrEmpty(path2, nameof(path2));
            var extension = Extensions.GetExtension(path1);

            if (!DiffTools.TryFind(extension, out var diffTool))
            {
                return;
            }

            var command = diffTool.BuildCommand(path1, path2);

            if (diffTool.IsMdi)
            {
                return;
            }

            ProcessCleanup.Kill(command);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Launch a diff tool for the given paths.
        /// </summary>
        public static void Launch(string path1, string path2)
        {
            Guard.AgainstNullOrEmpty(path1, nameof(path1));
            Guard.AgainstNullOrEmpty(path2, nameof(path2));
            var extension = Extensions.GetExtension(path1);

            if (launchedInstances >= maxInstancesToLaunch)
            {
                return;
            }

            if (!DiffTools.TryFind(extension, out var diffTool))
            {
                return;
            }

            //TODO: throw if both dont exist
            if (!File.Exists(path1))
            {
                if (!AllFiles.TryCreateFile(path1, true))
                {
                    return;
                }
            }

            if (!File.Exists(path2))
            {
                if (!AllFiles.TryCreateFile(path2, true))
                {
                    return;
                }
            }

            launchedInstances++;

            Launch(diffTool, path1, path2);
        }