Beispiel #1
0
        public CmpDirsParallel(string sourceDir, string targetDir, EnumOptions opts, DiffHandler diffHandler, ErrorHandler errorHandler, CancellationToken CtrlCEvent, int maxThreadsToRun)
        {
            _opts         = opts;
            _diffHandler  = diffHandler;
            _errorHandler = errorHandler;
            _CtrlCEvent   = CtrlCEvent;

            _executor = new Spi.ParallelExecutor <ParallelCtx, object, RootDirs>(
                initTL: () => new RootDirs(sourceDir, targetDir)
                , func: CompareTwoDirectories
                , freeTL: null
                , context: null
                , maxThreads: maxThreadsToRun
                , cancel: CtrlCEvent
                );
        }
Beispiel #2
0
        private void CompareTwoDirectories(ParallelCtx relativeDir, Spi.ParallelExecutor <ParallelCtx, object, RootDirs> executor, object ctx, ref RootDirs rootDir)
        {
            AppendDir(ref rootDir.source, relativeDir.dirToSearchSinceRootDir);
            AppendDir(ref rootDir.target, relativeDir.dirToSearchSinceRootDir);

            CmpDirs.Run(rootDir.source, rootDir.target,
                        (DIFF_STATE diffstate, Win32.FIND_DATA find_data_src, Win32.FIND_DATA find_data_trg) =>
            {
                GetDirToEnum(diffstate, ref find_data_src, ref find_data_trg, out string newDirToEnum, out uint attrs);

                if (newDirToEnum != null && WalkIntoDir(attrs, _opts.followJunctions, relativeDir.depth, _opts.maxDepth))
                {
                    executor.Enqueue(new ParallelCtx(Path.Combine(relativeDir.dirToSearchSinceRootDir, newDirToEnum), relativeDir.depth + 1));
                }

                //if (diffstate != DIFF_STATE.SAMESAME)
                //{
                _diffHandler(diffstate, relativeDir.dirToSearchSinceRootDir, ref find_data_src, ref find_data_trg);
                //}
            },