Created
September 14, 2012 07:40
-
-
Save flq/3720565 to your computer and use it in GitHub Desktop.
Prog to start a difftool and remap the files as they are deleted by git in order to open all files at once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<appSettings> | |
<add key="Toolpath" value="c:\tools\bc3\bcomp.exe" /> | |
<add key="RemoteDir" value="c:\users\foo\Desktop\compare" /> | |
</appSettings> | |
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Configuration; | |
using System.Diagnostics; | |
using System.IO; | |
namespace DifftoolStarter | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
try | |
{ | |
EnsureCompareDir(); | |
if (File.Exists(args[0])) | |
File.Copy(args[0], args[0] = CreateDestinationFile(args[0], "left")); | |
if (File.Exists(args[1])) | |
File.Copy(args[1], args[1] = CreateDestinationFile(args[1], "right")); | |
var toolPath = ConfigurationManager.AppSettings["Toolpath"]; | |
Process.Start(new ProcessStartInfo(toolPath, string.Join(" ", args))); | |
} | |
catch (Exception x) | |
{ | |
var ex = x; | |
while (ex != null) | |
{ | |
Console.WriteLine(x.GetType().Name); | |
Console.WriteLine(x.Message); | |
Console.WriteLine(x.StackTrace); | |
ex = x.InnerException; | |
} | |
Console.ReadLine(); | |
} | |
} | |
private static string CreateDestinationFile(string file, string subDir) | |
{ | |
var dir = ConfigurationManager.AppSettings["RemoteDir"]; | |
return Path.Combine(dir, subDir, Path.GetFileName(file)); | |
} | |
private static void EnsureCompareDir() | |
{ | |
var dir = ConfigurationManager.AppSettings["RemoteDir"]; | |
if (!Directory.Exists(dir)) | |
{ | |
Directory.CreateDirectory(dir); | |
Directory.CreateDirectory(Path.Combine(dir, "left")); | |
Directory.CreateDirectory(Path.Combine(dir, "right")); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment