Exemple #1
0
        private static List <DirectorySearchInfo> GatherDirectoriesToSearch()
        {
            List <DirectorySearchInfo> searchDirectories = new List <DirectorySearchInfo>();

            //Get a list of directories to ignore from the config file
            List <string> toIgnore = IgnoreMethods.GetIgnoreDirectories();

            toIgnore.Add("FileContentChecks");
            toIgnore.Add("ConfigCopPages");

            //Get the file types to search for as configured for the directory
            List <string> fTypes = HelperMethods.CheckConfiguration("fileTypes").Split(',').ToList <string>();

            //Add passed directory or working directory if none was passed
            if (IgnoreMethods.IgnorePath(toIgnore, Program.SearchDir) == false)
            {
                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine(Program.SearchDir);
                Console.ResetColor();
                AddSearchDirectory(searchDirectories, Program.SearchDir, fTypes, toIgnore);
            }

            //Get all the subdirectories
            List <string> subDirs = new List <string>();

            GetSubDirs(Program.SearchDir, toIgnore, subDirs);
            foreach (string subD in subDirs)
            {
                AddSearchDirectory(searchDirectories, subD, fTypes, toIgnore);
            }

            //Get all the additional directories to search from the config file
            string fullSearchDirs = HelperMethods.CheckConfiguration("searchDirsFull");

            if (!string.IsNullOrEmpty(fullSearchDirs))
            {
                string[] searchDirListFull = fullSearchDirs.Split(';');
                GatherConfiguredDirectories(searchDirectories, toIgnore, searchDirListFull, true);
            }
            string topSearchDirs = HelperMethods.CheckConfiguration("searchDirsTopOnly");

            if (!string.IsNullOrEmpty(topSearchDirs))
            {
                string[] searchDirListTop = topSearchDirs.Split(';');
                GatherConfiguredDirectories(searchDirectories, toIgnore, searchDirListTop, false);
            }

            return(searchDirectories);
        }