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/samples/Dtf/DDiff/FileDiffEngine.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/samples/Dtf/DDiff/FileDiffEngine.cs')
-rw-r--r-- | src/samples/Dtf/DDiff/FileDiffEngine.cs | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/src/samples/Dtf/DDiff/FileDiffEngine.cs b/src/samples/Dtf/DDiff/FileDiffEngine.cs deleted file mode 100644 index 20ecd857..00000000 --- a/src/samples/Dtf/DDiff/FileDiffEngine.cs +++ /dev/null | |||
@@ -1,83 +0,0 @@ | |||
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 | |||
6 | namespace WixToolset.Dtf.Samples.DDiff | ||
7 | { | ||
8 | public class FileDiffEngine : IDiffEngine | ||
9 | { | ||
10 | public FileDiffEngine() | ||
11 | { | ||
12 | } | ||
13 | |||
14 | public virtual float GetDiffQuality(string diffInput1, string diffInput2, string[] options, IDiffEngineFactory diffFactory) | ||
15 | { | ||
16 | if(diffInput1 != null && File.Exists(diffInput1) && | ||
17 | diffInput2 != null && File.Exists(diffInput2)) | ||
18 | { | ||
19 | return .10f; | ||
20 | } | ||
21 | else | ||
22 | { | ||
23 | return 0; | ||
24 | } | ||
25 | } | ||
26 | |||
27 | public bool GetDiff(string diffInput1, string diffInput2, string[] options, TextWriter diffOutput, string linePrefix, IDiffEngineFactory diffFactory) | ||
28 | { | ||
29 | bool difference = false; | ||
30 | |||
31 | FileInfo file1 = new FileInfo(diffInput1); | ||
32 | FileInfo file2 = new FileInfo(diffInput2); | ||
33 | |||
34 | if(file1.Length != file2.Length) | ||
35 | { | ||
36 | diffOutput.WriteLine("{0}File size: {1} -> {2}", linePrefix, file1.Length, file2.Length); | ||
37 | difference = true; | ||
38 | } | ||
39 | else | ||
40 | { | ||
41 | FileStream stream1 = file1.Open(FileMode.Open, FileAccess.Read, FileShare.Read); | ||
42 | FileStream stream2 = file2.Open(FileMode.Open, FileAccess.Read, FileShare.Read); | ||
43 | |||
44 | byte[] buf1 = new byte[512]; | ||
45 | byte[] buf2 = new byte[512]; | ||
46 | |||
47 | while(!difference) | ||
48 | { | ||
49 | int count1 = stream1.Read(buf1, 0, buf1.Length); | ||
50 | int count2 = stream2.Read(buf2, 0, buf2.Length); | ||
51 | |||
52 | for(int i = 0; i < count1; i++) | ||
53 | { | ||
54 | if(i == count2 || buf1[i] != buf2[i]) | ||
55 | { | ||
56 | difference = true; | ||
57 | break; | ||
58 | } | ||
59 | } | ||
60 | if(count1 < buf1.Length) // EOF | ||
61 | { | ||
62 | break; | ||
63 | } | ||
64 | } | ||
65 | |||
66 | stream1.Close(); | ||
67 | stream2.Close(); | ||
68 | |||
69 | if(difference) | ||
70 | { | ||
71 | diffOutput.WriteLine("{0}Files differ.", linePrefix); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | return difference; | ||
76 | } | ||
77 | |||
78 | public virtual IDiffEngine Clone() | ||
79 | { | ||
80 | return new FileDiffEngine(); | ||
81 | } | ||
82 | } | ||
83 | } | ||