Hello! Help is needed! I am writing a program that throughout the disk (Windows), must find files with the ini extension. Oddly enough, I write code in PHP, this is important .. Here is the code:

class ReadableFilter extends RecursiveFilterIterator{ public function accept(){ return $this->current()->isReadable(); } } function Search($dir, $ext){ $iterator = new ReadableFilter(new RecursiveDirectoryIterator($dir)); $iterator = new RecursiveIteratorIterator( $iterator ); $filter = new RegexIterator($iterator, '/^.+\.(?:'.$ext.')$/i', RecursiveRegexIterator::GET_MATCH); $filelist = array(); foreach($filter as $entry) { $filelist[] = $entry[0]; } return $filelist; } 

Well, now, it’s necessary to do something to make the code work quickly, otherwise it’s not reasonable to wait 10-15 or even 30 minutes, I don’t know, they can do some sort of restriction on the file size, or something else .. And who else understands this class, how can you restrict certain folders so that it does not search! Thank you in advance!

  • one
    Do not use regexp where string functions can do. Well, it seems to me that competently written native code will work several times faster. - Vladimir Martyanov
  • quickly? IMHO - you are asking for the impossible. hundreds of thousands, millions of files to sort through a couple of minutes is impossible. even the built-in OS will not give you that opportunity. still say that you have HDD)) but if you narrow the search to a couple of hundred, or better - tens of thousands of files - then another conversation. - Ivan Pshenitsyn

1 answer 1

Probably so for windows

 $bufer = array(); exec('find /ID:\\*.ini',$bufer); var_dump($bufer);