枚举文件
@param string $dirPath
@return \RecursiveIteratorIterator|\ArrayIterator
166181
public static function enum($dirPath)
    {
        if (!is_dir($dirPath)) {
            return new \ArrayIterator();
        }
        $iterator = new \RecursiveDirectoryIterator($dirPath, \FilesystemIterator::KEY_AS_PATHNAME | \FilesystemIterator::CURRENT_AS_FILEINFO | \FilesystemIterator::SKIP_DOTS);
        $files = new \RecursiveIteratorIterator($iterator);
        return $files;
    }
242357
protected function recursiveDeleteDir($path)
    {
        $path       = static::normalizerPath($path);
        $file_list  = $this->listContents($path);

        if ( is_array($file_list) && count($file_list) > 0 ) {
            foreach ($file_list as $file) {
                //如果是文件，则把文件删除
                if ($file['type'] == self::FILE_TYPE_FILE) {
                    $this->delete($path . $this->pathSeparator . $file['name']);
                } else {
                    $this->recursiveDeleteDir($path . $this->pathSeparator . $file['name']);
                }
            }
        }
        $this->getUpyun()->rmDir($path);
    }
232743
static function deleteDirectory($dirPath)
    {
        $dirPath = realpath($dirPath);
        if (!is_dir($dirPath)) return false;
        if (!static::cleanDirectory($dirPath)) return false;
        return rmdir(realpath($dirPath));
    }
1162567
public function createFolderIfNotExists($folderPath) {
        if (file_exists($folderPath) && is_dir($folderPath)) {
            return;
        }
        
        $arrFolder = explode(DIRECTORY_SEPARATOR, $folderPath);
        
        $fullPath = "";
        $first = true;
        foreach ($arrFolder as $folder) {
            if (!$folder) {
                continue; //Happens if the first char is a slash
            }
            if (!$first) {
                $fullPath .= DIRECTORY_SEPARATOR;
            } else {
                $first = false;
            }
            
            $fullPath .= $folder;
            
            try {
                $this->createSingleFolderIfNotExists($fullPath);
            } catch (Exception $e) {
                $msg = $e->getMessage();
                echo "Could not generate folder '".$fullPath."' <br />\n"
                        . $msg
                        . "<br />";
            }
        }        
    }
400328
public function getChunkDirectory($absolutePath = false)
    {
        $paths = [];

        if ($absolutePath) {
            $paths[] = $this->chunkStorage()->getDiskPathPrefix();
        }

        $paths[] = $this->chunkStorage()->directory();

        return implode('', $paths);
    }
1059167
public static function createDir($dirPath, $mode = 0711)
    {
        if (false === file_exists($dirPath)) {
            if (false === mkdir($dirPath, $mode, true)) {
                throw new RuntimeException(sprintf('unable to create directory "%s"', $dirPath));
            }
        }
    }
336999
protected function getConfigurationFiles($directoryPath)
    {
        $files = [];

        if (is_dir($directoryPath)) {
            foreach (Finder::create()->files()->in($directoryPath) as $file) {
                $group = basename($file->getRealPath(), '.php');
                $files[$group] = $file->getRealPath();
            }
        }

        return $files;
    }
352406
private function scanAreas($dirPath)
    {
        $dirPath = realpath($dirPath);

        if(strcmp($this->contentPath, $dirPath) > 0)
        {
            return;
        }

        if(is_dir($dirPath) && (($dir = @opendir($dirPath)) !== false))
        {
            while (($subDirName = readdir($dir)) !== false)
            {
                if(
                    ((substr($subDirName, 0, 1) == '.') || (substr($subDirName, 0, 1) == '_')) &&
                    $subDirName != '.' &&
                    $subDirName != '..' &&
                    is_dir($dirPath . DIRECTORY_SEPARATOR . $subDirName)
                ) {
                    $areaName = $subDirName;
                    //Searching for all areas
                    if(realpath($this->contentPath . $this->getNode()->getUri()) == $dirPath)
                    {
                        //normalize area name
                        $areaName = (substr($areaName, 1, 5) == 'tree_') ? substr($areaName, 6) : substr($areaName, 1);
                        $area = new Area($areaName, false);
                        $this->areas[$areaName] = $area;
                        $this->fillArea($area, $dirPath . DIRECTORY_SEPARATOR . $subDirName);
                    }
                    //Searching for areas to inherit only
                    else
                    {
                        if(substr($areaName, 1, 5) == 'tree_')
                        {
                            $areaName = substr($areaName, 6);

                            if(!$this->hasArea($areaName))
                            {
                                $area = new Area($areaName, true);
                                $this->areas[$areaName] = $area;
                                $this->fillArea($area, $dirPath . DIRECTORY_SEPARATOR . $subDirName);
                            }
                        }
                    }
                }
            }

            closedir($dir);
        }
        // @codeCoverageIgnoreStart
        else
        {
            throw new  PageException("Unable to read path");
        }
        // @codeCoverageIgnoreEnd

        $this->scanAreas($dirPath . '/..');
    }
368461
public function uploadFile(string $dirPath, string $fileName): bool
    {
        try {
            if (!$this->filesystem->createDir($dirPath)) {
                return false;
            }

            $targetFilePath = $dirPath . DIRECTORY_SEPARATOR . $fileName;

            if ($this->filesystem->has($targetFilePath)) {
                $this->addError('', "File by path `{$targetFilePath}` already exists.");

                return false;
            }

            $contentResource = $this->getFileContent();
            if ($contentResource === null) {
                return false;
            }

            return $this->filesystem->writeStream($targetFilePath, $contentResource);
        } catch (\Exception $e) {
            return false;
        }
    }
498254
public function getFilesOfDirs(array $dirs, $match = '/\.php$/')
    {
        $iterator = new AppendIterator();

        foreach ($dirs as $dir) {
            $iterator->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)));
        }

        return new RegexIterator($iterator, $match);
    }
647592
public static function GetDirContent($path)
    {
        $files = array();
        $directory = opendir($path);

        while(($file = readdir($directory)) !== false)
        {
            $full_path = $path . "/" . $file;

            if(is_file($full_path))
            {
                $files[] = $full_path;
            }
            elseif($file != "." && $file != ".." && is_dir($full_path))
            {
                $files[] = $full_path;
                $files = array_merge($files, self::GetDirContent($full_path));
            }
        }

        closedir($directory);

        return $files;
    }
876172
public function listFiles($path = '')
    {
        $directory = $this->getPath($path);
        if (!is_dir($directory)) {
            throw new RuntimeException(
                $directory . ' is not a directory.'
            );
        }

        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator(
                $this->getPath($path),
                RecursiveDirectoryIterator::SKIP_DOTS
            ),
            RecursiveIteratorIterator::SELF_FIRST
        );

        $files = [];

        /** @var SplFileInfo $fileInfo */
        foreach ($iterator as $fileInfo) {
            if ($fileInfo->isDir()) {
                continue;
            }

            $files[] = preg_replace(
                sprintf('/^%s/', preg_quote($this->root, '/')),
                '',
                $fileInfo->getPathname()
            );
        }

        return $files;
    }
147424
protected function getRecursiveDirectoryIterator($dir)
    {
        return new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($dir, \FilesystemIterator::CURRENT_AS_FILEINFO),
                \RecursiveIteratorIterator::SELF_FIRST,
                \RecursiveIteratorIterator::CATCH_GET_CHILD
                );
    }
892703
public static function deleteFolder($dirPath)
    {
        $it = new RecursiveDirectoryIterator($dirPath, RecursiveDirectoryIterator::SKIP_DOTS);
        $files = new RecursiveIteratorIterator(
            $it,
            RecursiveIteratorIterator::CHILD_FIRST
        );
        foreach ($files as $file) {
            if ($file->isDir()) {
                rmdir($file->getRealPath());
            } else {
                unlink($file->getRealPath());
            }
        }
        rmdir($dirPath);
    }
481208
private function getPhpFilesFromPath(string $path)
    {
        $directoryIterator = new RecursiveDirectoryIterator($path);
        foreach (new RecursiveIteratorIterator($directoryIterator) as $file) {
            if (! in_array($file->getExtension(), $this->fileExtensions)) {
                continue;
            }

            if ($this->fileShouldBeIgnored($file)) {
                continue;
            }

            $this->files->push(new File(['displayPath' => $file->getPathName(), 'fullPath' => $file->getRealPath()]));
        }
    }
1003330
public static function iterateDir( $startPath )
    {
        foreach( new \DirectoryIterator( $startPath ) as $objItem ) {
            if( $objItem->isLink( ) ) {
                Self::$arrSymlinks[] = $objItem->getPath( ) . '/' . $objItem->getFilename( );
                continue;
            }
            if($objItem->isDir( ) ) {
                if( !$objItem->isDot( ) ) Self::iterateDir( $objItem->getPathname(), $arrResult );
                continue;
            }
            if( $objItem->isLink() ) Self::$arrSymlinks[] = $objItem->getPath( ) . '/' . $objItem->getFilename( );
        }
        return;
    }
955882
public function setDirPath($dirPath)
    {
        $dirPath    = trim($dirPath);
        if ($this->filesystem->isDirectory($dirPath)) {
            $this->dirPath = $this->filesystem->realPath($dirPath);
        }
    }