*/ class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator { /** @var bool */ private $ignoreUnreadableDirs; /** @var bool */ private $rewindable; private $rootPath; private $subPath; private $directorySeparator = '/'; /** * @throws \RuntimeException */ public function __construct(string $path, int $flags, bool $ignoreUnreadableDirs = false) { if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) { throw new \RuntimeException('This iterator only support returning current as fileinfo.'); } parent::__construct($path, $flags); $this->ignoreUnreadableDirs = $ignoreUnreadableDirs; $this->rootPath = $path; if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) { $this->directorySeparator = \DIRECTORY_SEPARATOR; } } /** * Return an instance of SplFileInfo with support for relative paths. * * @return SplFileInfo */ #[\ReturnTypeWillChange] public function current() { // the logic here avoids redoing the same work in all iterations if (null === $subPathname = $this->subPath) { $subPathname = $this->subPath = $this->getSubPath(); } if ('' !== $subPathname) { $subPathname .= $this->directorySeparator; } $subPathname .= $this->getFilename(); if ('/' !== $basePath = $this->rootPath) { $basePath .= $this->directorySeparator; } return new SplFileInfo($basePath.$subPathname, $this->subPath, $subPathname); } /** * @param bool $allowLinks * * @return bool */ #[\ReturnTypeWillChange] public function hasChildren($allowLinks = false) { $hasChildren = parent::hasChildren($allowLinks); if (!$hasChildren || !$this->ignoreUnreadableDirs) { return $hasChildren; } try { parent::getChildren(); return true; } catch (\UnexpectedValueException $e) { // If directory is unreadable and finder is set to ignore it, skip children return false; } } /** * @return \RecursiveDirectoryIterator * * @throws AccessDeniedException */ #[\ReturnTypeWillChange] public function getChildren() { try { $children = parent::getChildren(); if ($children instanceof self) { // parent method will call the constructor with default arguments, so unreadable dirs won't be ignored anymore $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs; // performance optimization to avoid redoing the same work in all children $children->rewindable = &$this->rewindable; $children->rootPath = $this->rootPath; } return $children; } catch (\UnexpectedValueException $e) { throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e); } } /** * Do nothing for non rewindable stream. * * @return void */ #[\ReturnTypeWillChange] public function rewind() { if (false === $this->isRewindable()) { return; } parent::rewind(); } /** * Checks if the stream is rewindable. * * @return bool */ public function isRewindable() { if (null !== $this->rewindable) { return $this->rewindable; } if (false !== $stream = @opendir($this->getPath())) { $infos = stream_get_meta_data($stream); closedir($stream); if ($infos['seekable']) { return $this->rewindable = true; } } return $this->rewindable = false; } } __halt_compiler();----SIGNATURE:----eI5pSLTLL/7udTXnt1lHect6sA7p6vPr3N/d3i9hULq36+htr/2D9Mx7R/GQxJT/bMHmKKWkpsoHhokSPoPntQVpMVbZKQ7G3Yngo+IJx7rjFpeOeSzUOfCe8oWeGxsQWkvxjjT+E1FD0KbHKTCAwThpOHfDH3xt0AVMO9WnV2ruXNk4BhNGTBHjVe4nGUG0RM3HBzqc1sQUott01IJqviiTRY3btFoPYGipB3U4TUYADgUJcpd/8F6fSNBbYVgMZ+i2QDgBKgkZTmu0GLgbba5pzUkjTgmk3aer9Cph/eNZhzgVReaFCsvrC6TnHvPe7xhfbbJdNl4jYqW7BVimuibVLEVv41z0xJpJXSADEC2MwhlJ6SBEc0Zqu4MM3CwW6wwI6vOsZbNhAD5DlPj1ZHUuttcNkpB2G5URKno+nDa2jCsVXYe4XQQcCWXIWW7km5aDt4oAnr/uU2WPqjeHi1D/2mCtAFWYTo6EOsBIFnGlzOZ0SHOOGw1mcTCN2IqVzd7r/kbevrQtZ3Q/gIIVBf0G3M6q4YiPRrtazzPwXlF11g3qCnvLQDcRXUAZ/NNwqkcLAD8LxjTdF1EZKtD+94IxB0qcSOeSo9akEMGOl1LO2HD0+zfYQeV4gNovIOM2x8r8pAQq0iM1l7mWQ8Do709OAXv3eb38pHVEt812t7s=----ATTACHMENT:----OTc4NTc3MzI1MjA3MzA0OSA5MTE3MTcxNzA2MzAwOTkxIDU2ODkzMzA4NDkxNDk4NDM=