Skip to content

Commit 3eecc62

Browse files
conlinconlin
authored andcommitted
add dealFiles
1 parent 92c2e79 commit 3eecc62

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/helper/FileHelper.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,30 @@ public static function findFiles(string $dir, array $options = []): array
611611
return $list;
612612
}
613613

614+
/**
615+
* @param string $dir
616+
* @param array $options
617+
* @return array
618+
*/
619+
public static function dealFiles(string $dir, array $options = []): void
620+
{
621+
$dir = self::clearDir($dir);
622+
$options = self::setBasePath($dir, $options);
623+
$handle = self::openDir($dir);
624+
while (($file = readdir($handle)) !== false) {
625+
if ($file === '.' || $file === '..') {
626+
continue;
627+
}
628+
$path = $dir . DIRECTORY_SEPARATOR . $file;
629+
if (static::filterPath($path, $options)) {
630+
if (is_dir($path) && (!isset($options['recursive']) || $options['recursive'])) {
631+
static::findFiles($path, $options);
632+
}
633+
}
634+
}
635+
closedir($handle);
636+
}
637+
614638
/**
615639
* @param string $dir
616640
* @return string

0 commit comments

Comments
 (0)