Skip to content

Commit

Permalink
up: update some find logic and update some util method
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 16, 2023
1 parent 1d55ae4 commit 7ba7fd9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/Extra/FileFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ public function hasChildren(bool $allowLinks = false): bool
if (!$this->recursive) {
return false;
}

return parent::hasChildren($allowLinks);
}

Expand All @@ -743,7 +744,8 @@ public function getChildren(): RecursiveDirectoryIterator
return $children;
} catch (UnexpectedValueException $e) {
if ($this->skipUnreadableDirs) {
return new RecursiveArrayIterator([]);
return $this;
// return null;
// return new RecursiveDirectoryIterator([]);
}

Expand Down
18 changes: 16 additions & 2 deletions src/FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ public static function joinPath(string $basePath, string ...$subPaths): string
if (!$subPaths) {
return $basePath;
}
if (!$basePath) {
return implode(DIRECTORY_SEPARATOR, $subPaths);
}

return $basePath . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $subPaths);
}
Expand Down Expand Up @@ -253,15 +256,26 @@ public static function assertIsDir(string $dirPath): void
}
}

/**
* @param string $file
* @param string $type
*
* @return bool
*/
public static function exists(string $file, string $type = ''): bool
{
return self::isExists($file, $type);
}

/**
* 检查文件/夹/链接是否存在
*
* @param string $file 要检查的目标
* @param string $type
* @param string $type file, dir, link
*
* @return bool
*/
public static function exists(string $file, string $type = ''): bool
public static function isExists(string $file, string $type = ''): bool
{
if (!$type) {
return file_exists($file);
Expand Down

0 comments on commit 7ba7fd9

Please sign in to comment.