public function ls()
{
$pattern = null;
$dir = null;
$args = func_get_args();
$lst = array();
switch (count($args)) {
case 0:
$dir = getcwd();
case 1:
$dir = $this->app->path($args[0]);
break;
case 2:
$pattern = $args[0];
$dir = $this->app->path($args[1]);
break;
default:
return $lst;
}
if (!$dir || !file_exists($dir)) {
return $lst;
}
foreach (new \DirectoryIterator($dir) as $file) {
if ($file->isDot()) {
continue;
}
if ($pattern && !fnmatch($pattern, $file->getBasename())) {
continue;
}
$lst[] = new \SplFileObject($file->getRealPath());
}
return $lst;
}