コード例 #1
0
 private void Remove(SearchPath path)
 {
     foreach (var p in FPaths)
     {
         if ((p.Factory == path.Factory) && (p.Dir == path.Dir))
         {
             p.Dec();
         }
     }
 }
コード例 #2
0
        private void Add(SearchPath path)
        {
            bool found = false;

            foreach (var p in FPaths)
            {
                if ((p.Factory == path.Factory) && (String.Compare(p.Dir, path.Dir, true) == 0))
                {
                    p.Inc(path.IsUserDefined);
                    found = true;
                    break;
                }
            }

            if (!found)
            {
                foreach (var p in FPaths)
                {
                    // check for any parent path that is already covering the new subpath
                    // if found then disable the new path
                    if ((p.Recursive) && (p.Factory == path.Factory) && path.Dir.StartsWith(p.Dir, true, null))
                    {
                        path.DisableLater();
                        FLogger.Log(LogType.Debug, "adding disabled path " + path.Dir + " to available " + p.Factory.JobStdSubPath + ". already watched by: " + p.Dir);
                        FPaths.Add(path);
                        return;
                    }
                }

                if (path.Recursive)
                {
                    // new folder is set recursive, thus covering all its subfolders
                    // we need to check if any subfolders were already added and either disable them or add the new parent folder as not recursive
                    foreach (var p in FPaths)
                    {
                        if ((p.Factory == path.Factory) && p.Dir.StartsWith(path.Dir, true, null))
                        {
                            FLogger.Log(LogType.Debug, "adding recursive path " + path.Dir + " to available " + p.Factory.JobStdSubPath + ". conflicting with already added path: " + p.Dir);
                            FLogger.Log(LogType.Debug, "adding path as nonrecursive.");
                            p.DisableLater();
                            //path.Recursive = false;
                        }
                    }
                }

                FPaths.Add(path);
            }
        }