rendered paste bodyfunction baw_parse_dir($dir) {
global $BAW_CONF;
if (!file_exists($dir)) {
// echo baw_raise_error('datafilesdir', array($dir));
return array();
}
// add trailing slash if not exists
if (substr($dir, -1) != '/') {
$dir .= '/';
}
// baw_debug('dbg_start_parse_dir', $dir);
$files = array();
if ($dh = @opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if (!preg_match('/^\./s', $file)) {
if (is_dir($dir.$file)) {
$newdir = $dir.$file.'/';
chdir($newdir);
$files = array_merge($files, baw_parse_dir($newdir));
chdir('./..');
// baw_debug('dbg_found_dir', $dir);
} else {
$files[] = $dir.$file;
// baw_debug('dbg_found_file', $file);
}
}
}
}
// baw_debug('dbg_finished_parse_dir', $dir);
return $files;
}