function xautoload_DirScanner::scan in X Autoload 6
Same name and namespace in other branches
- 7 lib/DirScanner.php \xautoload_DirScanner::scan()
File
- ./xautoload.module, line 100
Class
- xautoload_DirScanner
Code
function scan($dir, $prefix) {
foreach (scandir($dir) as $candidate) {
if ($candidate == '.' || $candidate == '..') {
continue;
}
$path = $dir . '/' . $candidate;
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);
}
}
}
}