aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/count-code.php
diff options
context:
space:
mode:
Diffstat (limited to 'Neutron-trunk/count-code.php')
-rw-r--r--Neutron-trunk/count-code.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/Neutron-trunk/count-code.php b/Neutron-trunk/count-code.php
new file mode 100644
index 0000000..21a5c82
--- /dev/null
+++ b/Neutron-trunk/count-code.php
@@ -0,0 +1,34 @@
+<?php
+
+$cwd = getcwd();
+$found = 0;
+$size = 0;
+
+function crawl(string $dir) {
+ global $found;
+ global $size;
+ echo("(DIR) " . $dir . "\n");
+ $files = scandir($dir);
+ foreach ($files as $file) {
+ if (is_dir($dir . "/" . $file)) {
+ if ($file == "." || $file == ".." || $file == ".git") {} else {
+ crawl($dir . "/" . $file);
+ }
+ } else {
+ if (is_link($dir . "/" . $file)) {} else {
+ echo("(DOC) " . $dir . "/" . $file . "\n");
+ $size = $size + filesize($dir . "/" . $file);
+ $found = $found + count(file($dir . "/" . $file));
+ }
+ }
+ }
+ return $found;
+}
+
+if (PHP_SAPI === 'cli')
+{
+ echo("Couting lines...");
+ crawl($cwd);
+ echo("\nDONE!\n\nTotal code is " . $found . " lines long.");
+ echo("({$size} bytes)");
+}