Skip to content

Commit

Permalink
Added file comparison strategy to compare files byte-by-byte ignoring…
Browse files Browse the repository at this point in the history
… different styles of LineFeeds.
  • Loading branch information
Dirkster99 committed Aug 22, 2020
1 parent 3c2f9ec commit 5765c36
Show file tree
Hide file tree
Showing 23 changed files with 292 additions and 90 deletions.
1 change: 0 additions & 1 deletion source/AehnlichLib/AehnlichLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
<Compile Include="Enums\DiffType.cs" />
<Compile Include="Enums\EditType.cs" />
<Compile Include="Enums\HashType.cs" />
<Compile Include="Enums\DiffDirFileMode.cs" />
<Compile Include="Files\AsyncPump.cs" />
<Compile Include="Files\FileContentInfo.cs" />
<Compile Include="Files\FileEx.cs" />
Expand Down
41 changes: 21 additions & 20 deletions source/AehnlichLib/ClassDiagram1.cd
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="DiffLib.Dir.DiffUtility">
<Class Name="AehnlichLib.Dir.DiffUtility">
<Position X="19.25" Y="0.5" Width="3" />
<TypeIdentifier>
<HashCode>AAAAAQAAAAACAAAAEAAAAAAAAADAAEAAAAAAAAAAAAA=</HashCode>
<HashCode>AAAAAQgAAAAAAAAAEAAAAAAAAADEAEAAAAAAAAAAAAA=</HashCode>
<FileName>Dir\DiffUtility.cs</FileName>
</TypeIdentifier>
</Class>
Expand All @@ -78,14 +78,14 @@
<FileName>Dir\DirectoryDiffEntry.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Dir.DirectoryDiffEntryCollection">
<Class Name="AehnlichLib.Dir.DirectoryDiffEntryCollection">
<Position X="14.75" Y="4.75" Width="2.5" />
<TypeIdentifier>
<HashCode>AAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Dir\DirectoryDiffEntryCollection.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Dir.DirectoryDiffFileFilter">
<Class Name="AehnlichLib.Dir.DirectoryDiffFileFilter">
<Position X="22.5" Y="0.5" Width="2.25" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
Expand All @@ -95,16 +95,16 @@
<FileName>Dir\DirectoryDiffFileFilter.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Dir.FileSystemInfoComparer" BaseTypeListCollapsed="true">
<Class Name="AehnlichLib.Dir.FileSystemInfoComparer" BaseTypeListCollapsed="true">
<Position X="17.5" Y="4.75" Width="2" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAABABAAAAAAAAAAAAAAABACAAAAQA=</HashCode>
<FileName>Dir\FileSystemInfoComparer.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="DiffLib.Text.DiagonalVector">
<Position X="0.5" Y="5.5" Width="2.25" />
<Class Name="AehnlichLib.Text.DiagonalVector">
<Position X="0.75" Y="5.75" Width="2.25" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
</Compartments>
Expand All @@ -113,7 +113,7 @@
<FileName>Text\DiagonalVector.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Text.Edit">
<Class Name="AehnlichLib.Text.Edit">
<Position X="6.5" Y="0.5" Width="1.5" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
Expand All @@ -123,8 +123,8 @@
<FileName>Text\Edit.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Text.EditScript">
<Position X="8.25" Y="0.5" Width="1.5" />
<Class Name="AehnlichLib.Text.EditScript">
<Position X="8.25" Y="0.5" Width="1.75" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
</Compartments>
Expand All @@ -133,33 +133,34 @@
<FileName>Text\EditScript.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Text.MyersDiff&lt;T&gt;">
<Class Name="AehnlichLib.Text.MyersDiff&lt;T&gt;">
<Position X="2.25" Y="0.5" Width="2.25" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
<Compartment Name="Nested Types" Collapsed="false" />
</Compartments>
<NestedTypes>
<Struct Name="DiffLib.Text.MyersDiff&lt;T&gt;.Point" Collapsed="true">
<Struct Name="AehnlichLib.Text.MyersDiff&lt;T&gt;.Point" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>Text\MyersDiff.cs</NewMemberFileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Struct>
</NestedTypes>
<TypeIdentifier>
<HashCode>AIAAACAAAAAsAAYAAAQAAQAAAAAgEoAgACAAKAAAAIA=</HashCode>
<FileName>Text\MyersDiff.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Text.StringHasher">
<Position X="3" Y="5.5" Width="2.5" />
<Class Name="AehnlichLib.Text.StringHasher">
<Position X="3.25" Y="5.75" Width="2.5" />
<TypeIdentifier>
<HashCode>IAAAAAIACAAAAAAEAAAEAAAAAAAAAIAAIAAAAAAAAMA=</HashCode>
<FileName>Text\StringHasher.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Text.SubArray&lt;T&gt;">
<Position X="5.75" Y="5.5" Width="2.25" />
<Class Name="AehnlichLib.Text.SubArray&lt;T&gt;">
<Position X="6" Y="5.75" Width="2.25" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
</Compartments>
Expand All @@ -168,7 +169,7 @@
<FileName>Text\SubArray.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="DiffLib.Text.TextDiff">
<Class Name="AehnlichLib.Text.TextDiff">
<Position X="0.5" Y="0.5" Width="1.5" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
Expand All @@ -178,21 +179,21 @@
<FileName>Text\TextDiff.cs</FileName>
</TypeIdentifier>
</Class>
<Interface Name="DiffLib.Interfaces.IAddCopy">
<Interface Name="AehnlichLib.Interfaces.IAddCopy">
<Position X="34.5" Y="3.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interfaces\IAddCopy.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="DiffLib.Enums.EditType">
<Enum Name="AehnlichLib.Enums.EditType">
<Position X="4.75" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAEAAAABAAAAAAAAAAAAAAAEAAAAAAAAAAAEAAAA=</HashCode>
<FileName>Enums\EditType.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="DiffLib.Enums.HashType">
<Enum Name="AehnlichLib.Enums.HashType">
<Position X="4.75" Y="2.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAIAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAABAA=</HashCode>
Expand Down
2 changes: 1 addition & 1 deletion source/AehnlichLib/Dir/DirDiffArgs.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace AehnlichLib.Dir
{
using AehnlichLib.Enums;
using FsDataLib.Enums;

/// <summary>
/// Defines the arguments (options) that are applicable for the directory diff
Expand Down
4 changes: 2 additions & 2 deletions source/AehnlichLib/Dir/DirectoryDiff.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace AehnlichLib.Dir
{
using AehnlichLib.Dir.Merge;
using AehnlichLib.Enums;
using AehnlichLib.Interfaces;
using FsDataLib.Enums;
using FsDataLib.Interfaces.Dir;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -654,7 +654,7 @@ private void DiffFiles(DirectoryDiffRoot root,
{
try
{
if (root.Source.AreBinaryFilesDifferent(item.InfoA.FullName, item.InfoB.FullName) == true)
if (root.Source.AreBinaryFilesDifferent(item.InfoA.FullName, item.InfoB.FullName, root.DiffMode) == true)
different = true;
}
catch (System.IO.IOException ex)
Expand Down
2 changes: 1 addition & 1 deletion source/AehnlichLib/Dir/DirectoryDiffRoot.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace AehnlichLib.Dir
{
using AehnlichLib.Enums;
using AehnlichLib.Interfaces;
using FsDataLib.Enums;
using FsDataLib.Interfaces.Dir;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion source/AehnlichLib/Dir/FileSystemInfoComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace AehnlichLib.Dir

/// <summary>
/// Implements an internal class with static comparers for files and directories
/// to determine whehter files or directories are equal or not (based on their case-insensitive name).
/// to determine whether files or directories are equal or not (based on their case-insensitive name).
/// </summary>
internal class FileSystemInfoComparer : IComparer<IFileSystemInfo>, IComparer<IFileInfo>, IComparer<IDirectoryInfo>
{
Expand Down
3 changes: 2 additions & 1 deletion source/AehnlichLib/Text/ProcessTextDiff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using AehnlichLib.Files;
using AehnlichLib.Interfaces;
using AehnlichLib.Models;
using FsDataLib.Enums;
using FsDataLib.Interfaces.Dir;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -148,7 +149,7 @@ public IDiffProgress ProcessDiff(IDiffProgress progress, IDataSource dataSource)

#region TextLineConverter
/// <summary>
///
/// Compares two files using binary or text comparison methods.
/// </summary>
/// <param name="fileA"></param>
/// <param name="fileB"></param>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace AehnlichDirViewModelLib.Interfaces
{
using AehnlichLib.Enums;
using FsDataLib.Enums;

/// <summary>
/// Implements an interface to a viewmodel for a directory comparison mode that is used
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using AehnlichDirViewModelLib.Interfaces;
using AehnlichDirViewModelLib.ViewModels.Base;
using AehnlichLib.Dir;
using AehnlichLib.Enums;
using AehnlichLib.Interfaces;
using FsDataLib.Enums;
using FsDataLib.Interfaces.Dir;
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace AehnlichDirViewModelLib.ViewModels
{
using AehnlichDirViewModelLib.Interfaces;
using AehnlichLib.Enums;
using FsDataLib.Enums;

/// <summary>
/// Implements a viewmodel for a directory comparison mode that is used
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace AehnlichDirViewModelLib.ViewModels
{
using AehnlichDirViewModelLib.Interfaces;
using AehnlichLib.Enums;
using FsDataLib.Enums;
using System.Collections.Generic;

/// <summary>
Expand Down Expand Up @@ -93,14 +93,19 @@ private static IDiffFileModeItemViewModel CreateCompareFileModes(
"Compare each file by their length, last modification time, and byte-by-byte sequence",
DiffDirFileMode.ByteLength_LastUpdate_AllBytes));

diffFileModes.Add(new DiffFileModeItemViewModel("Byte Length + All Bytes",
"Compare each file by their length and byte-by-byte sequence",
DiffDirFileMode.ByteLength_AllBytes));
//// This is technically a duplicate with AllBytes
//// diffFileModes.Add(new DiffFileModeItemViewModel("Byte Length + All Bytes",
//// "Compare each file by their length and byte-by-byte sequence",
//// DiffDirFileMode.ByteLength_AllBytes));

diffFileModes.Add(new DiffFileModeItemViewModel("All Bytes",
"Compare each file by their Byte-by-byte sequence only",
"Compare each file by their length and byte-by-byte sequence",
DiffDirFileMode.AllBytes));

diffFileModes.Add(new DiffFileModeItemViewModel("All Bytes without LineFeeds",
"Compare each file by their byte-by-byte sequence but ignoring different LineFeeds in text files.",
DiffDirFileMode.ByteLength_AllBytes_IgnoreLf));

return defaultItem;
}
#endregion methods
Expand Down
26 changes: 13 additions & 13 deletions source/Demos/TextFileDemo/AehnlichFileDemo/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Window
x:Class="AehnlichDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:icon_src="clr-namespace:AehnlichViewLib.Themes;assembly=AehnlichViewLib"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:AehnlichViewModelsLib.Views;assembly=AehnlichViewModelsLib"
Title="Ähnlich"
Width="800"
Height="450"
Icon="{DynamicResource {x:Static icon_src:ResourceKeys.ICON_AehnlichKey}}"
mc:Ignorable="d">
x:Class="AehnlichDemo.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:icon_src="clr-namespace:AehnlichViewLib.Themes;assembly=AehnlichViewLib"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:AehnlichViewModelsLib.Views;assembly=AehnlichViewModelsLib"
Title="Ähnlich"
Width="800"
Height="450"
Icon="{DynamicResource {x:Static icon_src:ResourceKeys.ICON_AehnlichKey}}"
mc:Ignorable="d">

<views:FileDiffView Margin="3" />
<views:FileDiffView Margin="3" />

</Window>
89 changes: 89 additions & 0 deletions source/FsDataLib/ClassDiagram1.cd
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="FsDataLib.Dir.DirDataSource" BaseTypeListCollapsed="true">
<Position X="5.25" Y="3" Width="2.75" />
<TypeIdentifier>
<HashCode>AAAAAgAAEAAAAgAAAAQAAAAAAAAAAAAAAAABAAAAAQA=</HashCode>
<FileName>Dir\DirDataSource.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="FsDataLib.Dir.DirDataSourceFactory" BaseTypeListCollapsed="true">
<Position X="8.5" Y="3" Width="1.75" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Dir\DirDataSourceFactory.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="FsDataLib.Dir.DirectoryInfoImpl">
<Position X="0.5" Y="9" Width="2.5" />
<TypeIdentifier>
<HashCode>AAAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAgAAAA=</HashCode>
<FileName>Dir\DirectoryInfoImpl.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="FsDataLib.Dir.FileInfoImpl">
<Position X="3.25" Y="9" Width="2.25" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAACAAAABAAAAABgAABAAAAAAAAAAAAAAAQ=</HashCode>
<FileName>Dir\FileInfoImpl.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Class Name="FsDataLib.Dir.FileSystemInfoImpl">
<Position X="1.5" Y="5.5" Width="2.75" />
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
</Compartments>
<TypeIdentifier>
<HashCode>AAAAAAAAIAACAIAAAAAAAAQAAAAAAAAAAAABAAAAACA=</HashCode>
<FileName>Dir\FileSystemInfoImpl.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Interface Name="FsDataLib.Interfaces.Dir.IDataSource">
<Position X="5.25" Y="0.5" Width="2.75" />
<TypeIdentifier>
<HashCode>AAAAAgAAEAAAAgAAAAQAAAAAAAAAAAAAAAABAAAAAQA=</HashCode>
<FileName>Interfaces\Dir\IDataSource.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="FsDataLib.Interfaces.Dir.IDataSourceFactory">
<Position X="8.5" Y="0.5" Width="1.75" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interfaces\Dir\IDataSourceFactory.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="FsDataLib.Interfaces.Dir.IDirectoryInfo">
<Position X="2.5" Y="2.75" Width="2" />
<TypeIdentifier>
<HashCode>AAAAAAEAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAgAAAA=</HashCode>
<FileName>Interfaces\Dir\IDirectoryInfo.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="FsDataLib.Interfaces.Dir.IFileInfo">
<Position X="0.5" Y="2.75" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAABAAAAABAAABAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interfaces\Dir\IFileInfo.cs</FileName>
</TypeIdentifier>
</Interface>
<Interface Name="FsDataLib.Interfaces.Dir.IFileSystemInfo">
<Position X="1.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAIAAAAIAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>Interfaces\Dir\IFileSystemInfo.cs</FileName>
</TypeIdentifier>
</Interface>
<Enum Name="FsDataLib.Interfaces.Dir.FileType">
<Position X="10.5" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAEAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAABA=</HashCode>
<FileName>Interfaces\Dir\IFileInfo.cs</FileName>
</TypeIdentifier>
</Enum>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>
Loading

0 comments on commit 5765c36

Please sign in to comment.