You are here

function _flashnode_directorytoarray in Flash Node 5.6

Same name and namespace in other branches
  1. 5.3 flashnode.module \_flashnode_directorytoarray()
  2. 6.3 flashnode.import.inc \_flashnode_directorytoarray()
  3. 6.2 flashnode.import.inc \_flashnode_directorytoarray()

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

1 call to _flashnode_directorytoarray()
_flashnode_filesnotindb in ./flashnode.module
Return an array of files that are not currently in the {files} table

File

./flashnode.module, line 1262

Code

function _flashnode_directorytoarray($directory, $recursive) {
  $array_items = array();
  if ($handle = opendir($directory)) {
    while (false !== ($file = readdir($handle))) {
      if ($file != "." && $file != "..") {
        if (is_dir($directory . "/" . $file) && $file != 'temp') {
          if ($recursive) {
            $array_items = array_merge($array_items, _flashnode_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;
}