1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5 * An open source application development framework for PHP 5.1.6 or newer
8 * @author ExpressionEngine Dev Team
9 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10 * @license http://codeigniter.com/user_guide/license.html
11 * @link http://codeigniter.com
16 // ------------------------------------------------------------------------
19 * CodeIgniter Directory Helpers
21 * @package CodeIgniter
24 * @author ExpressionEngine Dev Team
25 * @link http://codeigniter.com/user_guide/helpers/directory_helper.html
28 // ------------------------------------------------------------------------
31 * Create a Directory Map
33 * Reads the specified directory and builds an array
34 * representation of it. Sub-folders contained with the
35 * directory will be mapped as well.
38 * @param string path to source
39 * @param int depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
42 if ( ! function_exists('directory_map'))
44 function directory_map($source_dir, $directory_depth = 0, $hidden = FALSE)
46 if ($fp = @opendir($source_dir))
49 $new_depth = $directory_depth - 1;
50 $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
52 while (FALSE !== ($file = readdir($fp)))
54 // Remove '.', '..', and hidden files [optional]
55 if ( ! trim($file, '.') OR ($hidden == FALSE && $file[0] == '.'))
60 if (($directory_depth < 1 OR $new_depth > 0) && @is_dir($source_dir.$file))
62 $filedata[$file] = directory_map($source_dir.$file.DIRECTORY_SEPARATOR, $new_depth, $hidden);
79 /* End of file directory_helper.php */
80 /* Location: ./system/helpers/directory_helper.php */