Skip to content

Commit

Permalink
fix: 修复目录扫描函数
Browse files Browse the repository at this point in the history
  • Loading branch information
zoujingli committed Oct 16, 2024
1 parent e239932 commit aa6b383
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugin/think-library/src/extend/ToolsExtend.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ public static function removeEmptyDirectory(string $path): bool
*/
public static function scanDirectory(string $path, ?int $depth = null, string $filterExt = '', bool $shortPath = true): array
{
return static::findFilesArray($path, $depth, static function (SplFileInfo $info) use ($filterExt) {
return !$filterExt || $info->getExtension() === $filterExt;
return static::findFilesArray($path, $depth, function (SplFileInfo $info) use ($filterExt, &$files) {
return $info->isDir() || $filterExt === '' || strtolower($info->getExtension()) === strtolower($filterExt);
}, $shortPath);
}

Expand Down Expand Up @@ -120,7 +120,7 @@ public static function findFilesArray(string $path, ?int $depth = null, ?Closure
* @param ?integer $depth 扫描深度
* @param \Closure|null $filter 文件过滤,返回 false 表示放弃
* @param boolean $appendPath 是否包含目录本身在结果中。
* @param integer $currDepth 当前递归深度,初始值为 0
* @param integer $currDepth 当前深度,临时变量递归时使用
* @return \Generator 返回 SplFileInfo 对象的生成器。
*/
private static function findFilesYield(string $path, ?int $depth = null, ?Closure $filter = null, bool $appendPath = false, int $currDepth = 1): Generator
Expand Down

0 comments on commit aa6b383

Please sign in to comment.