private int Count(string dir, string[] mask) { countblanklin=0; countcommentlines = 0; this.statusBar.Text = dir; this.statusBar.Update(); int totalCount = 0; string[] dirs = Directory.GetDirectories(dir); string dirName = dir.Substring(this.startPath.Length); foreach (string pattern in mask) { string[] filenames = Directory.GetFiles(dir, pattern); foreach (string file in filenames) { if (!running) return 0; int count = CountFile(file); if (count > 0) { string name = Path.GetFileName(file); TreeNode node = new TreeNode(name + " (" + count +")"); node.ImageIndex = 1; node.SelectedImageIndex = 1; listBox1.Items.Add(node); totalCount += count; FileEntry entry = new FileEntry(name, dirName, count); this.files.Add(entry); } } } return totalCount; } private int CountFile(string path) { int count = 0; countblanklin=0; countcommentlines=0; countifs=0; countelse=0; StatementCoverage = 0; Brain b = new Brain(); try { StreamReader reader = new StreamReader(path); String s; do { s = reader.ReadLine(); if (s != null) { count++; bool a = b.IsSource(s); if (b.CountIfs) countifs++; if ((b._isinsideif || b._isinsideelse) && (s.Trim().StartsWith(@"}") || s.Trim().StartsWith(@"else"))) b._isinsideif = false; if ((b._isinsideif || b._isinsideelse) && (s.Trim().StartsWith(@"}"))) b._isinsideelse = false; if ((b._isinsideif || b._isinsideelse) && !((s.Trim().StartsWith(@"if")) || (s.Trim().StartsWith(@"else")))) StatementCoverage++; if (b.CountElae) countelse++; if (b.CountMultiLineComments) countcommentlines++; } } while (s != null); reader.Close(); } catch (IOException) { } return count; } _____________________________________________ private void cmdCount_Click(object sender, System.EventArgs e) { DateTime then = DateTime.Now; System.Diagnostics.Process.GetCurrentProcess().ProcessorAffinity = (System.IntPtr)1; TimeSpan diff = DateTime.Now - then; } String.Format("{0:00}:{1:00}:{2:00}.{3:00}", (diff.Hours), diff.Minutes, diff.Sec
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)