1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
// 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.
using System;
using System.IO;
using System.Text;
namespace WixToolset.Dtf.Tools.DDiff
{
public class DDiff
{
public static void Usage(TextWriter w)
{
w.WriteLine("Usage: DDiff target1 target2 [options]");
w.WriteLine("Example: DDiff d:\\dir1 d:\\dir2");
w.WriteLine("Example: DDiff patch1.msp patch2.msp /patchtarget target.msi");
w.WriteLine();
w.WriteLine("Options:");
w.WriteLine(" /o [filename] Output results to text file (UTF8)");
w.WriteLine(" /p [package.msi] Diff patches relative to target MSI");
}
public static int Main(string[] args)
{
if(args.Length < 2)
{
Usage(Console.Out);
return -1;
}
string input1 = args[0];
string input2 = args[1];
string[] options = new string[args.Length - 2];
for(int i = 0; i < options.Length; i++) options[i] = args[i+2];
TextWriter output = Console.Out;
for(int i = 0; i < options.Length - 1; i++)
{
switch(options[i].ToLower())
{
case "/o": goto case "-output";
case "-o": goto case "-output";
case "/output": goto case "-output";
case "-output": output = new StreamWriter(options[i+1], false, Encoding.UTF8); break;
}
}
IDiffEngineFactory diffFactory = new BestQualityDiffEngineFactory(new IDiffEngine[]
{
new DirectoryDiffEngine(),
new FileDiffEngine(),
new VersionedFileDiffEngine(),
new TextFileDiffEngine(),
new MsiDiffEngine(),
new CabDiffEngine(),
new MspDiffEngine(),
});
IDiffEngine diffEngine = diffFactory.GetDiffEngine(input1, input2, options);
if(diffEngine != null)
{
bool different = diffEngine.GetDiff(input1, input2, options, output, "", diffFactory);
return different ? 1 : 0;
}
else
{
Console.Error.WriteLine("Dont know how to diff those inputs.");
return -1;
}
}
}
}
|