You are here

function _auditfiles_directorytoarray in Audit Files 6.3

Same name and namespace in other branches
  1. 5 auditfiles.module \_auditfiles_directorytoarray()
  2. 6.2 notindb.admin.inc \_auditfiles_directorytoarray()

Helper function - recurse directories and files in to an array http://snippets.dzone.com/posts/show/155

1 call to _auditfiles_directorytoarray()
_auditfiles_filesnotindb in ./notindb.admin.inc
Helper function - retrieve sorted list of files that are on the server but not in the database

File

./notindb.admin.inc, line 245
Callback and functions to generate files not in database report

Code

function _auditfiles_directorytoarray($directory, $recursive) {
  $array_items = array();
  if ($handle = opendir($directory)) {
    while (false !== ($file = readdir($handle))) {
      if ($file != "." && $file != "..") {
        if (is_dir($directory . "/" . $file)) {
          if ($recursive) {
            $array_items = array_merge($array_items, _auditfiles_directorytoarray($directory . "/" . $file, $recursive));
          }
          $file = $directory . "/" . $file;
          $array_items[] = preg_replace("/\\/\\//si", "/", $file);
        }
        else {
          $file = $directory . "/" . $file;
          $array_items[] = preg_replace("/\\/\\//si", "/", $file);
        }
      }
    }
    closedir($handle);
  }
  return $array_items;
}