예제 #1
0
        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());
        }
예제 #2
0
        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();
        }
예제 #3
0
 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);
             }
         }
     }));
 }