/** * Return true if path is dir and has at least one childs directory * * @param string $path dir path * @return bool * @author Dmitry (dio) Levashov **/ protected function _subdirs($path) { $dirs = false; if (is_dir($path)) { if (class_exists('FilesystemIterator', false)) { $dirItr = new ParentIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS | (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ? RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0))); $dirItr->rewind(); if ($dirItr->hasChildren()) { $dirs = true; $name = $dirItr->getSubPathName(); while ($name) { if (!$this->attr($path . DIRECTORY_SEPARATOR . $name, 'read', null, true)) { $dirs = false; $dirItr->next(); $name = $dirItr->getSubPathName(); continue; } $dirs = true; break; } } } else { $path = strtr($path, array('[' => '\\[', ']' => '\\]', '*' => '\\*', '?' => '\\?')); return (bool) glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*', GLOB_ONLYDIR); } } return $dirs; }
/** * Return true if path is dir and has at least one childs directory * * @param string $path dir path * @return bool * @author Dmitry (dio) Levashov **/ protected function _subdirs($path) { $dirs = false; if (is_dir($path)) { $dirItr = new ParentIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS | (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') ? RecursiveDirectoryIterator::FOLLOW_SYMLINKS : 0))); $dirItr->rewind(); if ($dirItr->hasChildren()) { $dirs = true; $name = $dirItr->getSubPathName(); while ($name) { if (!$this->attr($path . DIRECTORY_SEPARATOR . $name, 'read', null, true)) { $dirs = false; $dirItr->next(); $name = $dirItr->getSubPathName(); continue; } $dirs = true; break; } } } return $dirs; }