function listFiles($filenameFilter = NULL) { $path = StringBuffer::toStringBuffer($this->getFilePath()); $s = NULL; if (!isset($path)) { return array(); } $filter = isset($filenameFilter) ? $filenameFilter : new FilenameFilter(); $files = array(); $folders = array(); if ($this->exists() && $this->isDirectory()) { $path = $path->replace('/', DIRECTORY_SEPARATOR); if (!$path->endsWith(DIRECTORY_SEPARATOR)) { $path->append(DIRECTORY_SEPARATOR); } $handle = opendir($path->toString()); while ($file = readdir($handle)) { $filename = new StringBuffer($file); if (!$filename->equals('.') && !$filename->equals('..')) { $filename->prepend($path); $validfile = new File($filename); if ($filter->accept($validfile, $validfile->getParentDirectory())) { if ($validfile->isFile()) { $files[] = $validfile; } else { if ($validfile->isDirectory()) { $folders[] = $validfile; } } } } } closedir($handle); } return array_merge($folders, $files); }