Restricts the iteration to directories only.

@return $this
169038
function onlyDirectories ()
  {
    return $this->where (function ($f) {
      if (!is_object ($f) || !$f instanceof SplFileInfo)
        throw new \RuntimeException ("You must use FilesystemIterator::CURRENT_AS_PATHNAME with onlyDirectories() ");
      return $f->isDir ();
    });
  }
102921
public function clean()
    {
        // Make sure the handle is close
        $this->close();

        $dir = dirname($this->getFile());
        if (is_dir($dir)) {
            $files = scandir($dir);
            foreach ($files as $file) {
                if ('.' != $file && '..' != $file) {
                    $file = $dir . DIRECTORY_SEPARATOR .  $file;
                    if (is_file($file)) {
                        unlink($file);
                    }
                }
            }
        }
        return $this;
    }
1311743
public function removeDirs()
    {
        foreach ($this->removeDirs as $removeDir) {
            GeneralUtility::rmdir($removeDir, true);
        }
        $this->removeDirs = [];
    }
73389
public function inDir($dirs): self
    {
        $this->dirs = array_merge($this->dirs, (array)$dirs);

        return $this;
    }
1373457
public function setDir($dir = null){
        $this->databaseDir = (is_null($dir)) ? realpath(__DIR__).DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR : $dir;
        return $this;
    }
896330
public function isDirectory(): bool {
		if ($this->isRoot()) {
			return true;
		}

		$content = $this->manager->listContents(
			$this->getParent()->getUrl(),
			false
		);

		return count(
				array_filter(
					$content,
					function ($item) {
						if ($item["basename"] == $this->getName()) {
							return $item["type"] == "dir";
						}

						return false;
					}
				)
			) === 1;
	}
423571
protected function prepareMirrorDir()
    {
        $this->printTaskInfo(sprintf('Preparing directory %s.', $this->tmpDir));
        if (empty($this->ignoreFileNames)) {
            return;
        }
        $files = new Finder();
        $files->in($this->tmpDir);
        $files->ignoreDotFiles(false);
        $files->files();

        // Ignore files defined by the dev.
        foreach ($this->ignoreFileNames as $fileName) {
            $files->name($fileName);
        }
        $this->fs->remove($files);
    }
732465
public function deleteRecursively() {
		if ($this->exists()) {
			$entries = @\scandir($this->path);

			foreach ($entries as $entry) {
				if ($entry !== '.' && $entry !== '..') {
					$entryPath = $this->path . '/' . $entry;

					if (@\is_dir($entryPath)) {
						$this->deleteRecursively($entryPath);
					}
					else {
						@\unlink($entryPath);
					}
				}
			}

			@\rmdir($this->path);
		}
	}
264675
protected function restrict()
	{
		$length = strlen($this->data);

		if ($length > 0)
		{
			$this->data[$length - 1] = chr(ord($this->data[$length - 1]) & self::$restrict[$this->size % 8]);
		}

		return $this;
	}
452635
public function cleanupOutputDirectory()
    {
        $directoryIterator = new \RecursiveDirectoryIterator($this->outputDirectory, \RecursiveDirectoryIterator::SKIP_DOTS);

        /**
         * Items, which must not be deleted have to be skipped during the directory iteration
         *
         * @param \SplFileInfo $current
         * @return bool
         */
        $filterCallback = function (\SplFileInfo $current) {
            $skipItem = false === strpos($current->getFilename(), '.gitkeep') ? true : false;
            return $skipItem;
        };

        $filteredDirectoryIterator = new \RecursiveCallbackFilterIterator($directoryIterator, $filterCallback);
        $items = new \RecursiveIteratorIterator(
            $filteredDirectoryIterator,
            \RecursiveIteratorIterator::CHILD_FIRST
        );

        $this->fileSystem->remove($items);
    }
862586
protected function setThemeDirectory()
    {
        $pos = strrpos($this->dirPath, DIRECTORY_SEPARATOR);

        $this->directory = substr($this->dirPath, $pos + 1);
    }
268834
protected function scanDirectories()
    {
        $directories = $this->getDirectories();
        if (empty($directories)) {
            return;
        }

        //dd($directories);
        $scanner = $this->getScanner();

        $scanner->setDirectoriesToScan($directories);

        $scanner->scan();
    }
1295588
private function getDirectoryIterator()
    {
        $directoryIterator = new RecursiveDirectoryIterator($this->basePath);
        $directoryIterator->setFlags(RecursiveDirectoryIterator::SKIP_DOTS);

        return new RecursiveIteratorIterator($directoryIterator);
    }
734032
public function dirs(array $dirs)
    {
        foreach ($dirs as $k => $v) {
            if (is_numeric($v)) {
                $this->dir($k, $v);
                continue;
            }
            $this->dir($v);
        }

        return $this;
    }
636483
public function clear()
    {
        $this->paths = [];
        $this->names = [];
        $this->recursive = false;
        $this->file_only = false;
        $this->directory_only = false;
    }
157973
public static function clearAll()
    {
        $dir = new \DirectoryIterator(static::config('directory'));

        foreach ($dir as $fileinfo) {

            if ($fileinfo->isFile()) {
                $cacheKey = $fileinfo->getFilename();
                static::clear($cacheKey);
            }
        }
    }
844258
public function dir_rewinddir()
    {
        return $this->boolCall(function() {
            $this->objectIterator = null;
            $this->dir_opendir($this->openedPath, null);
            return true;
        });
    }