We create a Finder instance and check for files recursively in the given directories

@return void
772526
private function scanPaths()
    {
        foreach (Finder::create()->files()->in($this->pathsToScan)->name('*.' . $this->fileExtension) as $file) {
            $this->fileList->push($file->getRealPath());
        }
    }
828640
function filterFiles(files, recursive) {
    var fileOrDir = function fileOrDir(lstat) {
        return lstat.isFile() || lstat.isDirectory();
    };
    return files.filter(function (_ref) {
        var lstat = _ref.lstat;

        return recursive ? fileOrDir(lstat) : lstat.isFile();
    });
}
809252
protected function _searchFiles() {
		foreach ($this->_paths as $path) {
			$Folder = new Folder($path);
			$files = $Folder->findRecursive('.*\.(' . implode('|', $this->settings['files']) . ')', true);
			foreach ($files as $file) {
				if (strpos($file, DS . 'Vendor' . DS) !== false) {
					continue;
				}
				$this->_files[] = $file;
			}
		}
	}
994443
public function run()
    {
        $filesWithProblems = [];
        foreach ($this->_inspectFolders as $inspectFolder) {
            $directoryIterator = new RecursiveDirectoryIterator($this->_baseDir.'/'.$inspectFolder);
            $recursiveIterator = new RecursiveIteratorIterator($directoryIterator);
            $phpIterator = new RegexIterator($recursiveIterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH);

            foreach ($phpIterator as $filePath => $dummy) {
                $hasProblems = $this->_processFile($filePath);
                if ($hasProblems) {
                    $filesWithProblems[] = $filePath;
                }
            }
        }

        return $filesWithProblems;
    }
684665
protected function autoCreateDirs(array $dirs): void
    {
        foreach ($dirs as $dir) {
            if (! $this->files->exists($dir) && ! empty($dir)) {
                $this->files->makeDirectory($dir, 0755, true);
            }
        }
    }
302525
protected function reindexChildCheckers()
    {
        $this->fileEvents = array_fill_keys(array_keys($this->files), IN_DELETE);
        $this->dirEvents  = array_fill_keys(array_keys($this->directories), IN_DELETE);
        foreach ($this->getResource()->getFilteredResources() as $resource) {
            $basename = basename((string) $resource);
            if ($resource instanceof FileResource) {
                if (isset($this->files[$basename])) {
                    $this->fileEvents[$basename] = IN_MODIFY;
                } else {
                    $this->files[$basename] = $resource;
                    $this->fileEvents[$basename] = 'new';
                }
            } else {
                isset($this->directories[$basename])
                    ? $this->dirEvents[$basename] = IN_CREATE
                    : $this->createNewDirectoryChecker($basename, $resource);
            }
        }
        $this->watch();
    }
205537
public function recursiveRemoveDirectory($path)
    {
        $files = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::CHILD_FIRST
        );
        foreach ($files as $file) {
            if ($file->isDir()) {
                self::removeDirectory($file->getRealPath());
            } else {
                self::unlink($file->getRealPath());
            }
        }
        self::removeDirectory($path);
    }
186906
public function createCache()
    {
        // Check if there are files in the cache.
        // If not we will fill the cache, if there are we will check if there have been any changes to the enforced dirs
        $fileIterator = new \FilesystemIterator($this->getConfig()->getValue('cache/dir'), \FilesystemIterator::SKIP_DOTS);
        if (iterator_count($fileIterator) <= 1 || $this->getConfig()->getValue('environment') === 'development') {
            // Fill the cache
            $this->fillCache();

        } else {
            if (!$this->structureMap->isRecent()) {
                $this->refillCache();
            }
        }
    }
1065666
public function rewind()
    {
        if ($this->cacheFilesIterator === null) {
            $this->cacheFilesIterator = new \DirectoryIterator($this->cacheDirectory);
        }
        $this->cacheFilesIterator->rewind();
        while (substr($this->cacheFilesIterator->getFilename(), 0, 1) === '.' && $this->cacheFilesIterator->valid()) {
            $this->cacheFilesIterator->next();
        }
    }
1061114
protected function createFolders()
    {
        $dir    = null;
        $target = $this->getTargetDirectory();

        /** @noinspection IsEmptyFunctionUsageInspection */
        if (!empty($target)) {
            $dir = rtrim($target, '/') . DIRECTORY_SEPARATOR;
            $this->setTarget($dir);
        }

        if ($dir !== null && !is_dir($dir) && $this->isAllowCreateFolders()) {
            /** @noinspection NotOptimalIfConditionsInspection */
            /** @noinspection PhpUsageOfSilenceOperatorInspection */
            if (!@mkdir($dir, 0777, true) && !is_dir($dir)) {
                throw new Exception\NoSuchDirectoryException(
                    sprintf('Directory %s does not exists.', $dir)
                );
            }
        }
    }
116384
private function setDirectories($paths)
    {
        if (!empty($paths)) {
            foreach ($paths as $key => $dir) {
                $path = str_replace('.', DS, $dir);

                //Iterate through all paths and filter with extension provided
                $recursiveExtensionFilter = new FileExtensionFilter(
                    new \RecursiveDirectoryIterator($path)
                );

                // loop through the directory listing
                // we need to create a RecursiveIteratorIterator instance
                foreach ($recursiveExtensionFilter as $item) {
                    $alias = str_replace('.php', '', $item->getPathName());

                    $alias = implode('\\', array_map('ucfirst', explode(DS, $alias)));
                    if (!isset($this->directories[$alias])) {
                        $this->directories[str_replace('Src', '', $alias)] = str_replace('\\', '/', $item->getPathName());
                    }
                }
            }
        }
    }
936301
public function createDirs()
    {
        if (!is_dir($this->getMediaPath())) {
            mkdir($this->getMediaPath());
        }

        if (!is_dir($this->getThumbnailPath())) {
            mkdir($this->getThumbnailPath());
        }
    }
451561
private function checkDir($dir)
    {
        if (! $this->fs->exists($dir)) {
            $this->fs->mkdir($dir);
        }
    }
913584
public function folders($folders)
    {
        foreach((array) $folders as $folderPath)
        {
            if (! $this->file->exists($folderPath))
            {
                $this->file->makeDirectory($folderPath);
            }
        }
    }
616977
public static function rmdir( $dir ) {
		$files = new RecursiveIteratorIterator(
			new RecursiveDirectoryIterator( $dir, RecursiveDirectoryIterator::SKIP_DOTS ),
			RecursiveIteratorIterator::CHILD_FIRST
		);

		foreach ( $files as $fileinfo ) {
			$todo = $fileinfo->isDir() ? 'rmdir' : 'unlink';
			$todo( $fileinfo->getRealPath() );
		}
		rmdir( $dir );
	}
907476
function recursiveMkDir(dir) {
    if (!fs.existsSync(dir)) {
        recursiveMkDir(path.dirname(dir));
        fs.mkdirSync(dir);
    }
}
713751
public static function recursive($path)
    {
        if (is_dir($path)) {
            $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
            foreach ($iterator as $file) {
                self::_deleteFile($file);
            }
            rmdir($path);
        }
    }