Skip to content

Commit

Permalink
Always sort files in rsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
richardDobron committed Apr 19, 2023
1 parent 984418a commit 2d630a2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/fbt/helpers.php
Expand Up @@ -140,15 +140,20 @@ function unsignedRightShift($a, $b): int
return ($a & 0xFFFFFFFF) >> ($b & 0x1F);
}

function rsearch($folder, $pattern): \Generator
function rsearch($folder, $pattern): array
{
$dir = new \RecursiveDirectoryIterator($folder);
$ite = new \RecursiveIteratorIterator($dir);
$files = new \RegexIterator($ite, $pattern, \RegexIterator::MATCH);

$result = [];
foreach ($files as $file) {
yield $file->getPathName();
$result[] = $file->getPathName();
}

sort($result);

return $result;
}

/**
Expand Down

0 comments on commit 2d630a2

Please sign in to comment.