diff options
author | Rob Mensching <rob@firegiant.com> | 2022-07-14 15:19:53 -0700 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2022-07-14 16:02:24 -0700 |
commit | 229242cf7c328b89b5aa65ed7a04e33c8b93b393 (patch) | |
tree | de0a9547e73e46490b0946d6850228d5b30258b8 /src/tools/Dtf/DDiff/DDiff.cs | |
parent | f46ca6a9dce91607ffc9855270dd6998216e1a8b (diff) | |
download | wix-229242cf7c328b89b5aa65ed7a04e33c8b93b393.tar.gz wix-229242cf7c328b89b5aa65ed7a04e33c8b93b393.tar.bz2 wix-229242cf7c328b89b5aa65ed7a04e33c8b93b393.zip |
Rename "samples" segment to "tools"
This segment is a bit of a "miscellaneous section" in the WiX repo.
As such it has been difficult to name. I originally eschewed the
name "tools" because what is in the "wix" segment was once called
"tools". However, now that wix.exe is firmly established as the
entry point for WiX operations, I've become comfortable with its
segment being named "wix". That meant "tools" was again available
and "tools" better describes the content of this section.
Diffstat (limited to 'src/tools/Dtf/DDiff/DDiff.cs')
-rw-r--r-- | src/tools/Dtf/DDiff/DDiff.cs | 72 |
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 | |||
3 | using System; | ||
4 | using System.IO; | ||
5 | using System.Text; | ||
6 | |||
7 | namespace 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 | } | ||