Ejemplo n.º 1
0
 static function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE)
 {
     static $_filedata = array();
     if ($fp = @opendir($source_dir)) {
         // reset the array and make sure $source_dir has a trailing slash on the initial call
         if ($_recursion === FALSE) {
             $_filedata = array();
             $source_dir = rtrim(realpath($source_dir), DS) . DS;
         }
         while (FALSE !== ($file = readdir($fp))) {
             if (@is_dir($source_dir . $file) && strncmp($file, '.', 1) !== 0) {
                 FSFCF::get_filenames($source_dir . $file . DS, $include_path, TRUE);
             } elseif (strncmp($file, '.', 1) !== 0) {
                 $_filedata[] = $include_path == TRUE ? $source_dir . $file : $file;
             }
         }
         return $_filedata;
     } else {
         return FALSE;
     }
 }