title: RecursiveDirectoryIterator throws UnexpectedValueException on "Too many open files"
body: <p>The following code:</p>
  
  <pre><code>$zip = new ZipArchive();
  
  if ($zip-&gt;open('./archive.zip', ZIPARCHIVE::CREATE) !== TRUE) {
      die ("Could not open archive");
  }
  
  $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator("./folder/"));
  
  foreach ($iterator as $key =&gt; $value) {
    try {
      $zip-&gt;addFile(realpath($key), $key);
      echo "'$key' successfully added.\n";
    } catch (Exception $e) {
      echo "ERROR: Could not add the file '$key': $e\n";
    }
  }
  
  $zip-&gt;close();
  </code></pre>
  
  <p>Throws the following exception if there are too many files in a sub-folder which you're trying to iterate over:</p>
  
  <pre><code>Uncaught exception 'UnexpectedValueException' with message 'RecursiveDirectoryIterator::__construct(./some/path/): failed to open dir: Too many open files' in /some/other/path/zip.php:24
  Stack trace:
  #0 [internal function]: RecursiveDirectoryIterator-&gt;__construct('./some/path/')
  #1 /some/other/path/zip.php(24): RecursiveDirectoryIterator-&gt;getChildren()
  #2 {main}
  thrown in /some/other/path/zip.php on line 24
  </code></pre>
  
  <p>How can you successfully iterate over a large amount of folders and files without experiencing this exception?</p>