Changes between Version 2 and Version 3 of LinesOfCodeExample
- Timestamp:
- 12/12/06 17:25:30 (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
LinesOfCodeExample
v2 v3 32 32 char[] outputFileStr; 33 33 34 35 36 37 38 39 40 41 42 43 44 45 34 if(args.length < 3) 35 { 36 writefln("Usage: " ~ pgmName ~ " pattern input_path output_file"); 37 return 0; 38 } 39 else 40 { 41 patternStr = args[1]; 42 pathStr = args[2]; 43 outputFileStr = args[3]; 44 } 45 46 46 int n = listdirfn(pathStr, patternStr); 47 47 59 59 int n; 60 60 61 61 File fl; 62 62 63 63 bool callback(DirEntry* de) 64 64 { 65 65 if (de.isdir) 66 std.file.listdir(de.name, & callback);66 std.file.listdir(de.name, & callback); 67 67 else 68 68 { if (r.test(de.name)) 69 70 69 { 70 writefln("%s", de.name); 71 71 n++; 72 72 73 74 73 fl = new File(de.name); 74 int cntLn = 0; 75 75 76 77 78 79 80 cntLn++; 81 82 fl.close(); 83 84 85 76 while (!fl.eof()) 77 { 78 char[] line = strip(fl.readLine()); 79 if(line != "") /* don't count empty lines */ 80 cntLn++; 81 } 82 fl.close(); 83 outputData ~= `"` ~ de.name ~ `","` ~ toString(cntLn) ~ `"` ~ \r\n; 84 } 85 } 86 86 return true; // continue 87 87 } 88 88 89 std.file.listdir(pathname, & callback);89 std.file.listdir(pathname, & callback); 90 90 return n; 91 91 } 92 93 92 }}} 94 93