mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2026-06-12 14:28:09 +08:00
Update ToolsExtend.php
This commit is contained in:
parent
1b78f1bd28
commit
752680a7cc
@ -107,14 +107,14 @@ class ToolsExtend
|
|||||||
*/
|
*/
|
||||||
public static function findFilesArray(string $path, ?Closure $filterFile = null, ?Closure $filterPath = null, bool $short = true, ?int $depth = null): array
|
public static function findFilesArray(string $path, ?Closure $filterFile = null, ?Closure $filterPath = null, bool $short = true, ?int $depth = null): array
|
||||||
{
|
{
|
||||||
$files = [];
|
[$info, $files] = [new SplFileInfo($path), []];
|
||||||
if (is_file($path)) {
|
if ($info->isFile()) {
|
||||||
if (($file = new SplFileInfo($path)) && ($filterFile === null || $filterFile($file))) {
|
if ($filterFile === null || $filterFile($info)) {
|
||||||
$files[] = $short ? $file->getBasename() : $file->getPathname();
|
$files[] = $short ? $info->getBasename() : $info->getPathname();
|
||||||
}
|
}
|
||||||
} elseif (is_dir($path)) {
|
} elseif ($info->isDir()) {
|
||||||
foreach (static::findFilesYield($path, $filterFile, $filterPath, $depth) as $file) {
|
foreach (static::findFilesYield($info->getPathname(), $filterFile, $filterPath, $depth) as $file) {
|
||||||
$files[] = $short ? substr($file->getRealPath(), strlen($path) + 1) : $file->getRealPath();
|
$files[] = $short ? substr($file->getRealPath(), strlen($info->getPathname()) + 1) : $file->getRealPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $files;
|
return $files;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user