Beispiel #1
0
        bool IsExcludedFromIndex(string fullPath, bool isDirectory)
        {
            var excluded = ExcludedPaths.Any(u => fullPath.ToUpperInvariant().Contains(u)) ||
                           !isDirectory && ContainsExcludedExtension(fullPath);

            if (excluded)
            {
                Log.LogDebug($"{IndexConfig.IndexName}: {fullPath} is excluded from index, {(!isDirectory ? "check extension" : "not check extension")}");
            }

            return(excluded);
        }
Beispiel #2
0
        private void findResourcesInFolder(string folder, string baseFolder)
        {
            List <string> files = new List <string>();

            FileFilter.Split(';').ToList().ForEach(filter => { files = files.Concat(Directory.GetFiles(folder, filter)).ToList(); });

            files.AsParallel().ForAll(f =>
            {
                using (StreamReader stream = new StreamReader(f))
                {
                    int lineCount = 1;
                    int resCount  = 0;

                    string line = stream.ReadLine();

                    while (line != null)
                    {
                        if (line.Length < 250 && line.Length > 15)
                        {
                            patterns.ToList().ForEach(r =>
                            {
                                var matchCol = r.Matches(line);
                                for (int i = 0; i < matchCol.Count; i++)
                                {
                                    var m = matchCol[i];
                                    if (m.Groups["key"] != null)
                                    {
                                        addMatch(f, line, lineCount, m);
                                        ++resCount;
                                    }
                                }
                            });
                        }
                        ++lineCount;
                        line = stream.ReadLine();
                    }

                    Console.Out.WriteLine("*** " + f.Substring(baseFolder.Length) + " " + resCount);
                }
            });
            if (RecursiveSearchEnabled)
            {
                string[] directories = Directory.GetDirectories(folder);
                if (directories != null)
                {
                    directories
                    .Where(d => !ExcludedPaths.Any(p => p.Equals(Path.GetFileName(d), StringComparison.CurrentCultureIgnoreCase)) && !ExcludedPaths.Any(p => p.Equals(d, StringComparison.CurrentCultureIgnoreCase))).ToList()
                    .ForEach(d => findResourcesInFolder(d, baseFolder));
                }
            }
        }
Beispiel #3
0
        bool IsExcludedFromIndex(string fullPath, WatcherChangeTypes changeType)
        {
            if (changeType == WatcherChangeTypes.Deleted) // Unable to determine path is folder or file under deleted scenario
            {
                var excluded  = ExcludedPaths.Any(u => fullPath.ToUpperInvariant().Contains(u));
                var extension = Path.GetExtension(fullPath).ToUpperInvariant();

                if (extension != string.Empty)
                {
                    excluded = excluded || ExcludedExtensions.Contains(extension) || IncludedExtensions.Length > 0 && !IncludedExtensions.Contains(extension);
                }

                if (excluded)
                {
                    Log.LogDebug($"{IndexConfig.IndexName}: {fullPath} is excluded from index, change type: {WatcherChangeTypes.Deleted}");
                }

                return(excluded);
            }

            return(IsExcludedFromIndex(fullPath, IsDirectory(fullPath)));
        }
    /// <summary>
    /// Checks if the file should be excluded from the deletion.
    /// </summary>
    /// <param name="path">Full path to the file.</param>
    private bool IsFileExcluded(string path)
    {
        var relativePath = path.Substring(DirsToSearch.Where(path.StartsWith).First().Length + 1);

        return(ExcludedPaths.Any(relativePath.StartsWith));
    }