You are here

function bg_iterative_recurse_dir in Brilliant Gallery 7.2

Same name and namespace in other branches
  1. 5.4 brilliant_gallery.module \bg_iterative_recurse_dir()
  2. 5.3 brilliant_gallery.module \bg_iterative_recurse_dir()
  3. 6.4 brilliant_gallery.module \bg_iterative_recurse_dir()
  4. 6 brilliant_gallery.module \bg_iterative_recurse_dir()
  5. 6.2 brilliant_gallery.module \bg_iterative_recurse_dir()
  6. 6.3 brilliant_gallery.module \bg_iterative_recurse_dir()
  7. 7 brilliant_gallery.module \bg_iterative_recurse_dir()

File

./OLD_brilliant_gallery.module, line 239

Code

function bg_iterative_recurse_dir($from = '.') {
  if (!is_dir($from)) {
    return FALSE;
  }
  $files = array();
  $dirs = array(
    $from,
  );
  while (NULL !== ($dir = array_pop($dirs))) {
    if ($dh = opendir($dir)) {
      while (FALSE !== ($file = readdir($dh))) {
        if ($file == '.' || $file == '..') {
          continue;
        }
        $path = $dir . '/' . $file;
        if (is_dir($path)) {
          $dirs[] = $path;
        }
        else {
          $files[] = $path;
        }
      }
      closedir($dh);
    }
  }
  return $files;
}