aboutsummaryrefslogtreecommitdiff
path: root/Neutron-trunk/count-code.php
blob: 21a5c82e61343b19a8ad34d32e1b56ac4ce635e7 (plain)
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
<?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)");
}