private void ParseFiles(CompareSets set) { // scan directories var files = ListFiles(set.Path); // set files set.FileList = files; totalFiles += files.Count; int wt, cpt; ThreadPool.GetMaxThreads(out wt, out cpt); // files file comparision var tasks = new List <Task>(); foreach (var file in set.FileList) { tasks.Add(Task.Run(() => { var data = FileCompareData.FromFile(file, set.Path); lock (set) { set.AllFiles.Add(data); set.Files[data.absolutePath] = data; Filenames.Add(data.name); } ++fileScanIndex; })); } Task.WaitAll(tasks.ToArray()); }
public CrossCompare(FileCompareData left, FileCompareData right, int similarity) { var lData = left.absolutePath.Contains(DirectoryBrowse.LeftPath) ? left : right; var rData = left.absolutePath.Contains(DirectoryBrowse.LeftPath) ? right : left; this.left = lData; this.right = rData; this.similarity = similarity; CreateCompareString(); }
private Task AddToSet(CrossCompareSet set, FileCompareData left, FileCompareData right, int similarity = -1) { return(Task.Run(() => { if (left.extension == right.extension) { var min = changedRules[left.extension]; var cc = similarity == -1 ? new CrossCompare(left, right) : new CrossCompare(left, right, similarity); if (cc.similarity >= min) { lock (set) set.Add(cc); } } })); }