private static void RunCompare(Opts opts, CancellationToken CtrlCEvent, TextWriter errWriter) { DateTime start = DateTime.Now; using (DiffWriter diffWriters = new DiffWriter()) { Stats stats = new Stats(); var enumOpts = new EnumOptions() { followJunctions = opts.FollowJunctions, maxDepth = opts.Depth, forceSortSource = opts.forceSortSource, forceSortTarget = opts.forceSortTarget }; DiffProcessing diffProcessor = new DiffProcessing(stats, diffWriters, opts.reportSameFile); string src = Spi.Long.GetLongFilenameNotation(opts.sourceDir.TrimEnd('\\')); string trg = Spi.Long.GetLongFilenameNotation(opts.targetDir.TrimEnd('\\')); Console.Error.WriteLine($"source: {src}\ntarget: {trg}"); var paraCmp = new CmpDirsParallel( sourceDir: src, targetDir: trg, opts: enumOpts, diffHandler: diffProcessor.DiffCallback, errorHandler: (int RetCode, string Message) => { Interlocked.Increment(ref stats.Errors); errWriter.WriteLine($"E: rc={RetCode}\t{Message}"); }, CtrlCEvent: CtrlCEvent, maxThreadsToRun: opts.MaxThreads); paraCmp.Start(); StatusLineWriter statWriter = new StatusLineWriter(); using (Process currProc = System.Diagnostics.Process.GetCurrentProcess()) { Misc.ExecUtilWaitHandleSet(paraCmp.Finished, 2000, () => WriteProgress(stats, currProc, paraCmp.Queued, paraCmp.Running, paraCmp.Done, statWriter)); } WriteStatistics(new TimeSpan(DateTime.Now.Ticks - start.Ticks), paraCmp.Done, stats); if (stats.Errors > 0) { Console.Error.WriteLine($"{stats.Errors} erros occoured. please see file {opts.errorFilename}."); } } }
public DiffProcessing(Stats stats, DiffWriter writers, bool writeSameSame) { _stats = stats; _writers = writers; _writeSameSame = writeSameSame; }