UpdateList() публичный Метод

public UpdateList ( string strPath, string strFile, string strExt, string strHit, int intLineNumber, string strLine ) : void
strPath string
strFile string
strExt string
strHit string
intLineNumber int
strLine string
Результат void
Пример #1
0
        /// <summary>
        /// Scan a particular file
        /// </summary>
        /// <param name="strFile">the file we wish to scan</param>
        /// <param name="strAPIs">an array of regular expressions we've loaded</param>
        /// <returns></returns>
        private bool ScanFile(string strFile)
        {
            if (engineLocal.bStopped == true)
            {
                engineLocal.LowerQueueCount();
                return(false);
            }

            try
            {
                frmMaster.UpdateProgess();
                byte[] fileBytes = File.ReadAllBytes(strFile);
                if (IsBinary(fileBytes))
                {
                    //Console.WriteLine("Skipped " + strFile + " due to being binary");
                    return(false);
                }

                string[] strLines = File.ReadAllLines(strFile);
                FileInfo fInfo    = new FileInfo(strFile);

                int intCount = 0;

                foreach (string strLine in strLines)
                {
                    intCount++;

                    Match commentregexMatch = null;
                    if (bComments == true)
                    {
                        try
                        {
                            foreach (string strComRegex in strCommentsRegex)
                            {
                                commentregexMatch = Regex.Match(strLine, strComRegex);
                                if (commentregexMatch.Success == true)
                                {
                                    //Console.WriteLine("1!! " + strLine + " - " + strComRegex);
                                    break;
                                }
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }

                    if (bComments != true || commentregexMatch == null || (commentregexMatch != null && commentregexMatch.Success == false))
                    {
                        foreach (string strRegex in strAPIs)
                        {
                            if (engineLocal.bStopped == true)
                            {
                                engineLocal.LowerQueueCount();
                                return(false);
                            }

                            try
                            {
                                //Console.WriteLine("[!] " + strLine);

                                Match regexMatch = null;
                                if (bCase == true)
                                {
                                    regexMatch = Regex.Match(strLine, strRegex, RegexOptions.IgnoreCase);
                                }
                                else
                                {
                                    regexMatch = Regex.Match(strLine, strRegex);
                                }


                                if (regexMatch != null && regexMatch.Success)
                                {
                                    // Update the GUI
                                    frmMaster.UpdateList(fInfo.DirectoryName, fInfo.Name, fInfo.Extension, strRegex, intCount, strLine);
                                }
                            }
                            catch (Exception)
                            {
                                //Console.WriteLine(rExp.Message);
                            }
                        }
                    }
                    else
                    {
                        //Console.WriteLine(strLine + " is a comment " + commentregexMatch.Success);
                    }
                }

                fInfo    = null;
                strLines = null;
            }
            catch (Exception)
            {
            }
            finally
            {
                //Console.WriteLine("Finally..");
                engineLocal.LowerQueueCount();
            }

            return(true);
        }