Example #1
0
        public List <KeywordMatch> DetectSearch(SearchParams context, string file)
        {
            List <KeywordMatch> matches = new List <KeywordMatch>();
            var contentType             = DetectFileType(file);

            switch (contentType)
            {
            case FileContentType.Binary:
            {
                SearchBinary bin = new SearchBinary(m_terminate);
                matches = bin.Search(context, file);
            }
            break;

            case FileContentType.Text:
            default:
            {
                SearchText text = new SearchText(m_terminate);
                matches = text.Search(context, file);
            }
            break;
            }

            return((matches == null || matches.Count() == 0) ? null : matches);
        }
Example #2
0
        public List <KeywordMatch> Search(SearchParams context, string file)
        {
            m_terminate.Reset();

            List <KeywordMatch> matches = null;

            switch (context.FileType)
            {
            case FileContentType.Text:
            {
                SearchText text = new SearchText(m_terminate);
                matches = text.Search(context, file);
            }
            break;

            case FileContentType.Binary:
            {
                SearchBinary bin = new SearchBinary(m_terminate);
                matches = bin.Search(context, file);
                break;
            }

            case FileContentType.Detect:
                matches = DetectSearch(context, file);
                break;
            }
            return(matches);
        }
Example #3
0
        public static FileContentType DetectFileType(string file)
        {
            if (SearchBinary.IsMine(file))
            {
                return(FileContentType.Binary);
            }
            else if (SearchText.IsMine(file))
            {
                return(FileContentType.Text);
            }

            return(FileContentType.None);
        }