Skip to content

Commit 7ba7fd9

Browse files
committed
up: update some find logic and update some util method
1 parent 1d55ae4 commit 7ba7fd9

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/Extra/FileFinder.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ public function hasChildren(bool $allowLinks = false): bool
726726
if (!$this->recursive) {
727727
return false;
728728
}
729+
729730
return parent::hasChildren($allowLinks);
730731
}
731732

@@ -743,7 +744,8 @@ public function getChildren(): RecursiveDirectoryIterator
743744
return $children;
744745
} catch (UnexpectedValueException $e) {
745746
if ($this->skipUnreadableDirs) {
746-
return new RecursiveArrayIterator([]);
747+
return $this;
748+
// return null;
747749
// return new RecursiveDirectoryIterator([]);
748750
}
749751

src/FileSystem.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ public static function joinPath(string $basePath, string ...$subPaths): string
201201
if (!$subPaths) {
202202
return $basePath;
203203
}
204+
if (!$basePath) {
205+
return implode(DIRECTORY_SEPARATOR, $subPaths);
206+
}
204207

205208
return $basePath . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $subPaths);
206209
}
@@ -253,15 +256,26 @@ public static function assertIsDir(string $dirPath): void
253256
}
254257
}
255258

259+
/**
260+
* @param string $file
261+
* @param string $type
262+
*
263+
* @return bool
264+
*/
265+
public static function exists(string $file, string $type = ''): bool
266+
{
267+
return self::isExists($file, $type);
268+
}
269+
256270
/**
257271
* 检查文件/夹/链接是否存在
258272
*
259273
* @param string $file 要检查的目标
260-
* @param string $type
274+
* @param string $type file, dir, link
261275
*
262276
* @return bool
263277
*/
264-
public static function exists(string $file, string $type = ''): bool
278+
public static function isExists(string $file, string $type = ''): bool
265279
{
266280
if (!$type) {
267281
return file_exists($file);

0 commit comments

Comments
 (0)