function coder_upgrade_scan_directory_2 in Coder 7.2
Same name and namespace in other branches
- 7 coder_upgrade/conversions/end.inc \coder_upgrade_scan_directory_2()
Scans a directory and finds all files and/or directories beneath it.
@todo Move to .inc file in parent directory.
Parameters
string $dirname: Directory path to scan.
Return value
array Array of file and/or directory names.
1 call to coder_upgrade_scan_directory_2()
- coder_upgrade_upgrade_end_alter in coder_upgrade/
conversions/ end.inc - Implements hook_upgrade_end_alter().
File
- coder_upgrade/
conversions/ end.inc, line 49 - Provides conversion routines applied to the directory after routines are applied to the files.
Code
function coder_upgrade_scan_directory_2($dirname, $retrieve = 'dirs') {
$dirs = array();
if (!is_dir($dirname)) {
return $dirs;
}
static $ignore = array(
/*'.', '..', '.bzr', '.git', '.svn',*/
'CVS',
);
$files = scandir($dirname);
$dirname .= '/';
foreach ($files as $key => $file) {
$file_path = $dirname . $file;
if (substr(basename($file_path), 0, 1) == '.' || in_array(basename($file_path), $ignore)) {
// Ignore all hidden directories and CVS directory.
unset($files[$key]);
}
elseif (is_dir($file_path)) {
unset($files[$key]);
$files[$key]['dir'] = $file;
$files[$key]['entries'] = coder_upgrade_scan_directory_2($file_path, $retrieve);
$dirs[] = $file;
}
}
return $retrieve == 'dirs' ? $dirs : $files;
}