From 229242cf7c328b89b5aa65ed7a04e33c8b93b393 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 14 Jul 2022 15:19:53 -0700 Subject: 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. --- src/samples/Dtf/DDiff/VersionedFileDiffEngine.cs | 90 ------------------------ 1 file changed, 90 deletions(-) delete mode 100644 src/samples/Dtf/DDiff/VersionedFileDiffEngine.cs (limited to 'src/samples/Dtf/DDiff/VersionedFileDiffEngine.cs') diff --git a/src/samples/Dtf/DDiff/VersionedFileDiffEngine.cs b/src/samples/Dtf/DDiff/VersionedFileDiffEngine.cs deleted file mode 100644 index ad4014f3..00000000 --- a/src/samples/Dtf/DDiff/VersionedFileDiffEngine.cs +++ /dev/null @@ -1,90 +0,0 @@ -// 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 WixToolset.Dtf.WindowsInstaller; - -namespace WixToolset.Dtf.Samples.DDiff -{ - public class VersionedFileDiffEngine : IDiffEngine - { - public VersionedFileDiffEngine() - { - } - - private bool IsVersionedFile(string file) - { - return Installer.GetFileVersion(file) != ""; - } - - public float GetDiffQuality(string diffInput1, string diffInput2, string[] options, IDiffEngineFactory diffFactory) - { - if(diffInput1 != null && File.Exists(diffInput1) && - diffInput2 != null && File.Exists(diffInput2) && - (IsVersionedFile(diffInput1) || IsVersionedFile(diffInput2))) - { - return .20f; - } - else - { - return 0; - } - } - - public bool GetDiff(string diffInput1, string diffInput2, string[] options, TextWriter diffOutput, string linePrefix, IDiffEngineFactory diffFactory) - { - bool difference = false; - - string ver1 = Installer.GetFileVersion(diffInput1); - string ver2 = Installer.GetFileVersion(diffInput2); - - if(ver1 != ver2) - { - diffOutput.WriteLine("{0}File version: {1} -> {2}", linePrefix, ver1, ver2); - difference = true; - } - else - { - FileStream stream1 = new FileStream(diffInput1, FileMode.Open, FileAccess.Read, FileShare.Read); - FileStream stream2 = new FileStream(diffInput2, FileMode.Open, FileAccess.Read, FileShare.Read); - - byte[] buf1 = new byte[512]; - byte[] buf2 = new byte[512]; - - while(!difference) - { - int count1 = stream1.Read(buf1, 0, buf1.Length); - int count2 = stream2.Read(buf2, 0, buf2.Length); - - for(int i = 0; i < count1; i++) - { - if(i == count2 || buf1[i] != buf2[i]) - { - difference = true; - break; - } - } - if(count1 < buf1.Length) // EOF - { - break; - } - } - - stream1.Close(); - stream2.Close(); - - if(difference) - { - diffOutput.WriteLine("{0}File versions match but bits differ.", linePrefix); - } - } - - return difference; - } - - public IDiffEngine Clone() - { - return new VersionedFileDiffEngine(); - } - } -} -- cgit v1.2.3-55-g6feb