public static function globDir($pattern, $flags = 0, $recursive = true)
{
// parse the first directory
$files = glob($pattern, $flags);
// parse all subdirectories, if recursive parsing is wanted
if ($recursive !== false) {
foreach (glob(dirname($pattern) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR | GLOB_NOSORT | GLOB_BRACE) as $dir) {
$files = array_merge($files, FileSystem::globDir($dir . DIRECTORY_SEPARATOR . basename($pattern), $flags));
}
}
// return the array with the files matching the glob pattern
return $files;
}