Example #1
0
        private void FindNotUsedCpp()
        {
            ProgressEvent.Exec("Begin", 0, ProgressEventType.Start);
            ProgramState = ProgramStates.Worked;

            ListToPanel(GetDelete(_allFiles.Count(f => f.Type == AllFilesClass.ExtType.MakeFile),
                                  Convert.ToInt32(comboBoxThreadsCount.Text),
                                  new List <AllFilesClass>(_allFiles.Where(f => f.Type == AllFilesClass.ExtType.CppFile)),
                                  @"\b(?<word>\w+)\.cp?p?\b", new List <AllFilesClass.ExtType> {
                AllFilesClass.ExtType.MakeFile
            }, s => s));

            ProgramState = ProgramStates.WaitAction;
            ProgressEvent.Exec("Complete Find Not Used Cpp", 100, ProgressEventType.End);
        }
Example #2
0
        private void FindNotUsedFor()
        {
            ProgressEvent.Exec("Begin", 0, ProgressEventType.Start);
            ProgramState = ProgramStates.Worked;

            ListToPanel(
                GetDelete(
                    _allFiles.Count(
                        f => f.Type == AllFilesClass.ExtType.CppFile || f.Type == AllFilesClass.ExtType.HppFile),
                    Convert.ToInt32(comboBoxThreadsCount.Text),
                    new List <AllFilesClass>(_allFiles.Where(f => f.Type == AllFilesClass.ExtType.ForFile)),
                    @"[""](?<word>\w+)[.][f][o][r][""]",
                    new List <AllFilesClass.ExtType> {
                AllFilesClass.ExtType.CppFile, AllFilesClass.ExtType.HppFile
            },
                    ParseFor));

            ProgramState = ProgramStates.WaitAction;
            ProgressEvent.Exec("Complete Find Not Used For", 100, ProgressEventType.End);
        }
Example #3
0
        private void FindNotUsedHpp()
        {
            ProgressEvent.Exec("Begin", 0, ProgressEventType.Start);
            ProgramState = ProgramStates.Worked;

            ListToPanel(
                GetDelete(
                    _allFiles.Count(
                        f => f.Type == AllFilesClass.ExtType.CppFile || f.Type == AllFilesClass.ExtType.HppFile),
                    Convert.ToInt32(comboBoxThreadsCount.Text),
                    new List <AllFilesClass>(_allFiles.Where(f => f.Type == AllFilesClass.ExtType.HppFile)),
                    @".*#\s*include\s*.*(<|\"").*(>|"")",
                    new List <AllFilesClass.ExtType> {
                AllFilesClass.ExtType.CppFile, AllFilesClass.ExtType.HppFile
            },
                    ParseHeader));

            ProgramState = ProgramStates.WaitAction;
            ProgressEvent.Exec("Complete Find Not Used Hpp", 100, ProgressEventType.End);
        }
Example #4
0
        private void GetDelete(object sendToThread)
        {
            var obj = sendToThread as SendToThreadClass;

            if (obj == null)
            {
                throw new NullReferenceException("sendToThread can be only SendToThreadClass");
            }

            var rgx = new Regex(obj.Pattern, RegexOptions.IgnoreCase);

            foreach (var s in _allFiles.Where(af => obj.TypesFind.Contains(af.Type)).Skip(obj.Skip).Take(obj.Take))
            {
                int current;
                lock (obj.Counter)
                {
                    current = obj.Counter.Count++;
                }

                try
                {
                    using (var f = new FileStream(s.Address, FileMode.Open))
                    {
                        using (var r = new StreamReader(f, _encoding))
                        {
                            var matches = rgx.Matches(r.ReadToEnd());
                            if (matches.Count > 0)
                            {
                                foreach (Match match in matches)
                                {
                                    if (match.Value.ToLower().Contains(@"//"))
                                    {
                                        continue;
                                    }
                                    lock (obj.List)
                                    {
                                        obj.List.RemoveAll(
                                            af =>
                                            string.Equals(af.Name, obj.ProcessMatch(match.Value),
                                                          StringComparison.CurrentCultureIgnoreCase));
                                    }
                                }
                            }
                            r.Close();
                        }
                        f.Close();
                    }
                    ProgressEvent.Exec($"Process {current}/{obj.Count} ({GetPercent(current, obj.Count)}%)",
                                       GetPercent(current, obj.Count), ProgressEventType.Update);
                }
                catch (UnauthorizedAccessException unauthorizedAccessException)
                {
                    BMTools.BmDebug.Debug.Crit("UnauthorizedAccessException=", unauthorizedAccessException.Message, unauthorizedAccessException.StackTrace);
                    throw;
                }
                catch (Exception e)
                {
                    BMTools.BmDebug.Debug.Crit("Unknown Exception=", e.GetType(), e.Message, e.StackTrace);
                    throw;
                }
            }
        }