aboutsummaryrefslogtreecommitdiff
path: root/src/tools/Dtf/DDiff/DDiff.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/Dtf/DDiff/DDiff.cs')
-rw-r--r--src/tools/Dtf/DDiff/DDiff.cs72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/tools/Dtf/DDiff/DDiff.cs b/src/tools/Dtf/DDiff/DDiff.cs
new file mode 100644
index 00000000..4e9121b6
--- /dev/null
+++ b/src/tools/Dtf/DDiff/DDiff.cs
@@ -0,0 +1,72 @@
1// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
3using System;
4using System.IO;
5using System.Text;
6
7namespace WixToolset.Dtf.Tools.DDiff
8{
9 public class DDiff
10 {
11 public static void Usage(TextWriter w)
12 {
13 w.WriteLine("Usage: DDiff target1 target2 [options]");
14 w.WriteLine("Example: DDiff d:\\dir1 d:\\dir2");
15 w.WriteLine("Example: DDiff patch1.msp patch2.msp /patchtarget target.msi");
16 w.WriteLine();
17 w.WriteLine("Options:");
18 w.WriteLine(" /o [filename] Output results to text file (UTF8)");
19 w.WriteLine(" /p [package.msi] Diff patches relative to target MSI");
20 }
21
22 public static int Main(string[] args)
23 {
24 if(args.Length < 2)
25 {
26 Usage(Console.Out);
27 return -1;
28 }
29
30 string input1 = args[0];
31 string input2 = args[1];
32 string[] options = new string[args.Length - 2];
33 for(int i = 0; i < options.Length; i++) options[i] = args[i+2];
34
35 TextWriter output = Console.Out;
36
37 for(int i = 0; i < options.Length - 1; i++)
38 {
39 switch(options[i].ToLower())
40 {
41 case "/o": goto case "-output";
42 case "-o": goto case "-output";
43 case "/output": goto case "-output";
44 case "-output": output = new StreamWriter(options[i+1], false, Encoding.UTF8); break;
45 }
46 }
47
48 IDiffEngineFactory diffFactory = new BestQualityDiffEngineFactory(new IDiffEngine[]
49 {
50 new DirectoryDiffEngine(),
51 new FileDiffEngine(),
52 new VersionedFileDiffEngine(),
53 new TextFileDiffEngine(),
54 new MsiDiffEngine(),
55 new CabDiffEngine(),
56 new MspDiffEngine(),
57 });
58
59 IDiffEngine diffEngine = diffFactory.GetDiffEngine(input1, input2, options);
60 if(diffEngine != null)
61 {
62 bool different = diffEngine.GetDiff(input1, input2, options, output, "", diffFactory);
63 return different ? 1 : 0;
64 }
65 else
66 {
67 Console.Error.WriteLine("Dont know how to diff those inputs.");
68 return -1;
69 }
70 }
71 }
72}