function &glob($pattern, $dirpath, $pattern_type = 'php')
{
$dh = @opendir($dirpath);
if (!$dh) {
$pe = PEAR::raiseError("Cannot open directory {$dirpath}");
return $pe;
}
$match_function = File_Find::_determineRegex($pattern, $pattern_type);
$matches = array();
// empty string cannot be specified for 'php' and 'perl' pattern
if ($pattern || $pattern_type != 'php' && $pattern_type != 'perl') {
while (false !== ($entry = @readdir($dh))) {
if ($match_function($pattern, $entry) && $entry != '.' && $entry != '..') {
$matches[] = $entry;
}
}
}
@closedir($dh);
if (0 == count($matches)) {
$matches = null;
}
sort($matches);
return $matches;
}