forked from anegostudios/vsmodelcreator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinecounter.php
42 lines (31 loc) · 1.09 KB
/
linecounter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
$subcounts = array();
$totallines = countLines("src/at/vintagestory", array(""), array("Mat4f.java"));
$subcounts = array_reverse($subcounts);
foreach ($subcounts as $subcount) {
echo $subcount;
}
echo "\r\nTotal lines: " . number_format($totallines);
function countLines($folder, $excludefoldernames, $excludefilenames, $depth = 0) {
global $subcounts;
$lines = 0;
$dir = opendir($folder);
while ($file = readdir($dir)) {
if (preg_match("#\.java$#", $file) && !in_array($file, $excludefilenames)) {
$lines += count(file($folder . '/' . $file));
}
if (is_dir($folder . '/' . $file) && $file != '.' && $file != '..' && !in_array($file, $excludefoldernames)) {
$linesOfDir = countLines($folder . '/' . $file, $excludefoldernames, $excludefilenames, $depth + 1);
if ($depth < 3 && $linesOfDir > 0) {
$prefix = pad($depth) . $file;
$subcounts[] = $prefix . pad(15 - strlen($prefix)/2) . number_format($linesOfDir ) . "\r\n";
}
$lines += $linesOfDir ;
}
}
return $lines;
}
function pad($depth) {
if ($depth <= 0) return "";
return str_repeat(" ", $depth);
}