You are here

class xautoload_DirScanner in X Autoload 6

Same name and namespace in other branches
  1. 7 lib/DirScanner.php \xautoload_DirScanner

Hierarchy

Expanded class hierarchy of xautoload_DirScanner

File

./xautoload.module, line 92

View source
class xautoload_DirScanner {
  protected $locations;
  function __construct(array &$locations) {
    $this->locations =& $locations;
  }
  function scan($dir, $prefix) {
    foreach (scandir($dir) as $candidate) {
      if ($candidate == '.' || $candidate == '..') {
        continue;
      }
      $path = $dir . '/' . $candidate;

      // TODO: Strict checking for valid identifier strings
      if (preg_match('#^(.+)\\.inc$#', $candidate, $m)) {
        if (is_file($path)) {
          $name = $prefix . '_' . $m[1];
          $this->locations[$name] = $path;
        }
      }
      elseif (preg_match('#^(.+)$#', $candidate, $m)) {
        if (is_dir($path)) {
          $this
            ->scan($path, $prefix . '_' . $candidate);
        }
      }
    }
  }

}

Members