Example #1
0
        public IDiffProgress ProcessDiff(IDiffProgress progress)
        {
            progress.ShowIndeterminatedProgress();

            try
            {
                if (System.IO.File.Exists(_Args.A) == false ||
                    System.IO.File.Exists(_Args.B) == false)
                {
                    return(progress);
                }

                IList <string> a, b;
                int            leadingCharactersToIgnore = 0;

                if (_Args.DiffType == DiffType.File)
                {
                    GetFileLines(_Args.A, _Args.B, out a, out b, out leadingCharactersToIgnore, _Args, progress);
                }
                else
                {
                    GetTextLines(_Args.A, _Args.B, _Args, out a, out b, progress);
                }

                IsBinaryCompare      = leadingCharactersToIgnore > 0;
                IgnoreCase           = IsBinaryCompare ? false : _Args.IgnoreCase;
                IgnoreTextWhitespace = IsBinaryCompare ? false : _Args.IgnoreTextWhitespace;
                TextDiff diff = new TextDiff(_Args.HashType, IgnoreCase, IgnoreTextWhitespace, leadingCharactersToIgnore, !_Args.ShowChangeAsDeleteInsert);

                ListA  = a;
                ListB  = b;
                Script = diff.Execute(a, b);

                progress.ResultData = this;

                return(progress);
            }
            finally
            {
                progress.ProgressDisplayOff();
            }
        }
Example #2
0
        /// <summary>
        /// Compares <paramref name="directoryA"/> with <paramref name="directoryB"/> using the comparison
        /// options as defined in the constructor of this class.
        /// </summary>
        /// <param name="directoryA"></param>
        /// <param name="directoryB"></param>
        /// <param name="progress"></param>
        /// <param name="source"></param>
        /// <returns>Null if an unkown error occured or if either directory cannot be accessed
        /// (or does not exist), otherwise returns a <see cref="IDiffProgress"/> object
        /// where the <see cref="IDiffProgress.ResultData"/> property contains a
        /// <see cref="IDirectoryDiffRoot"/> data structure that describes the directory
        /// differences in detail.</returns>
        public IDiffProgress Execute(IDirectoryInfo directoryA,
                                     IDirectoryInfo directoryB,
                                     IDiffProgress progress,
                                     IDataSource source)
        {
            try
            {
                // Create a faux base entry to pass to Execute
                var diffRoot = new DirectoryDiffRoot(directoryA.FullName,
                                                     directoryB.FullName,
                                                     _Recursive, _Filter, _DiffMode, source);

                progress.ResultData = diffRoot;
                progress.ShowIndeterminatedProgress();

                if (directoryA.Exists == false || directoryB.Exists == false)
                {
                    return(null);
                }

                // directory diff match
                int directories = this.BuildSubDirs(directoryA, directoryB,
                                                    _Recursive, _Filter, diffRoot);

                progress.ShowDeterminatedProgress(0, 0, directories);
                this.AddFiles(diffRoot, progress);

                return(progress);
            }
            catch (Exception exp)
            {
                progress.LogException(exp);
                return(null);
            }
            finally
            {
                progress.ProgressDisplayOff();
            }
        }