枚举php文件
@param string $dirPath
@return \RegexIterator|ArrayIterator
972456
public static function enumPHPFile($dirPath)
    {
        if (!is_dir($dirPath)) {
            return new \ArrayIterator();
        }
        $directory = new \RecursiveDirectoryIterator($dirPath);
        $iterator = new \RecursiveIteratorIterator($directory);
        $regex = new \RegexIterator($iterator, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH);
        return $regex;
    }
120497
public static function dirname(string $path): string
    {
        $dirname = dirname($path);

        return self::normalizeDirname($dirname);
    }
289955
public function checkDocument($path = __DIR__) {
        $file = [];
        #需要截取的本地字符串长度
        $leng = strlen($path);
        foreach ($this->file_list['file'] as $key => $value) {
            $name = substr($value, $leng);
            #获取文件唯一码
            $unique = str_replace(DS, "_", $name);
            #获取唯一建
            $key = MD5($unique);
            #获取文件信息
            $file[$key]['code'] = MD5(file_get_contents($value));
            $file[$key]['name'] = $name;
            $file[$key]['time'] = filemtime($value);
        }
        return $file;
    }
1298916
public function createDirectory($dirPath)
    {
      if (! $this->fs->exists($dirPath))
      {
        $this->fs->mkdir($dirPath);
      }
    }
1043111
public function extract($filePath)
    {
        $directory = $this->directory->getDirectoryPath();
        $pharArchive = new PharData($filePath, null, null, Phar::GZ);
        $pharArchive->extractTo($directory);

        return $this->createFinderFromDirectory($directory);
    }
98105
public function findPhp($path)
    {
        $allFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path));
        $phpFiles = new RegexIterator($allFiles, '/\.php$/');
        $files = array();
        foreach ($phpFiles as $phpFile) {
            $filename = $phpFile->getRealpath();
            $content = file_get_contents($filename);
            $files[] = new File($filename, $content);
        }

        return $files;
    }
1153734
protected function getFileIterator($path, $pattern = '/^.+\.php$/')
    {
        if (is_dir($path)) {
            return new \RegexIterator(new \DirectoryIterator($path), $pattern, \RegexIterator::GET_MATCH);
        }
        if (is_file($path) && 1 === preg_match($pattern, $path)) {
            return [new \SplFileInfo($path)];
        }
        return [];
    }
484644
protected function _scandir($path) {
		return isset($this->dirsCache[$path])
			? $this->dirsCache[$path]
			: $this->cacheDir($path);
	}
1010577
public function relativizePath($absolutePath): string
    {
        $absolutePath = $this->normalizeSlashes($absolutePath);

        // see if the path is even in the root
        if (false === strpos($absolutePath, $this->rootDirectory)) {
            return $absolutePath;
        }

        $absolutePath = $this->realPath($absolutePath);

        // str_replace but only the first occurrence
        $relativePath = ltrim(implode('', explode($this->rootDirectory, $absolutePath, 2)), '/');
        if (0 === strpos($relativePath, './')) {
            $relativePath = substr($relativePath, 2);
        }

        return is_dir($absolutePath) ? rtrim($relativePath, '/').'/' : $relativePath;
    }
217266
static function scanDirectory($dirPath)
    {
        if (!is_dir($dirPath)) return false;
        $dirPath = realpath($dirPath) . '/';
        $dirs = array( $dirPath );

        $fileContainer = array();
        $dirContainer = array();

        try {
            do {
                $workDir = array_pop($dirs);
                $scanResult = scandir($workDir);
                foreach ($scanResult as $files) {
                    if ($files == '.' || $files == '..') continue;
                    $realPath = $workDir . $files;
                    if (is_dir($realPath)) {
                        array_push($dirs, $realPath . '/');
                        $dirContainer[] = $realPath;
                    } elseif (is_file($realPath)) {
                        $fileContainer[] = $realPath;
                    }
                }
            } while ($dirs);
        } catch (\Throwable $throwable) {
            return false;
        }

        return [ 'files' => $fileContainer, 'dirs' => $dirContainer ];
    }
262415
public function extract($filePath)
    {
        $directory = $this->directory->getDirectoryPath();
        $pharArchive = new Phar($filePath);
        $pharArchive->extractTo($directory);

        return $this->createFinderFromDirectory($directory);
    }
955882
public function setDirPath($dirPath)
    {
        $dirPath    = trim($dirPath);
        if ($this->filesystem->isDirectory($dirPath)) {
            $this->dirPath = $this->filesystem->realPath($dirPath);
        }
    }
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);
    }
1121660
private function scanDirectory($directoryPath)
    {
        if (is_dir($directoryPath)) {
            $files = scandir($directoryPath);
            foreach ($files as $fileName) {
                $filePath = Path::join($directoryPath, $fileName);
                if (is_dir($filePath) && !in_array($fileName, ['.', '..'])) {
                    $this->scanDirectory($filePath);
                } elseif ($this->searchForFileName == strtolower($fileName)) {
                    $this->filePaths[] = $filePath;
                }
            }
        }
    }
78875
public static function find_or_make($folderPath)
    {
        // Safely split all parts
        $parts = array_filter(preg_split("#[/\\\\]+#", $folderPath));

        $parentID = 0;
        $item = null;
        $filter = FileNameFilter::create();
        foreach ($parts as $part) {
            if (!$part) {
                continue; // happens for paths with a trailing slash
            }

            // Ensure search includes folders with illegal characters removed, but
            // err in favour of matching existing folders if $folderPath
            // includes illegal characters itself.
            $partSafe = $filter->filter($part);
            $item = Folder::get()->filter(array(
                'ParentID' => $parentID,
                'Name' => array($partSafe, $part)
            ))->first();

            if (!$item) {
                $item = new Folder();
                $item->ParentID = $parentID;
                $item->Name = $partSafe;
                $item->Title = $part;
                $item->write();
            }
            $parentID = $item->ID;
        }

        return $item;
    }
392242
public static String normalizeDirPath(String dirPath) {
        if (dirPath == null || dirPath.isEmpty())
            return "";

        dirPath = dirPath.replace("\\", "/");

        if (!dirPath.endsWith("/")) {
            dirPath = dirPath + "/";
        }

        return dirPath;
    }
889338
private function getMime($filePath)
    {
        $file = new File($filePath);
        $mime = $file->getMime();

        if (is_array($mime)) {
            $mime = reset($mime);
        }

        return $mime;
    }