Derek Allard | d2df9bc | 2007-04-15 17:41:17 +0000 | [diff] [blame] | 1 | <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
| 2 | /**
|
| 3 | * CodeIgniter
|
| 4 | *
|
| 5 | * An open source application development framework for PHP 4.3.2 or newer
|
| 6 | *
|
| 7 | * @package CodeIgniter
|
| 8 | * @author Rick Ellis
|
| 9 | * @copyright Copyright (c) 2006, EllisLab, Inc.
|
| 10 | * @license http://www.codeignitor.com/user_guide/license.html
|
| 11 | * @link http://www.codeigniter.com
|
| 12 | * @since Version 1.0
|
| 13 | * @filesource
|
| 14 | */
|
| 15 |
|
| 16 | // ------------------------------------------------------------------------
|
| 17 |
|
| 18 | /**
|
| 19 | * CodeIgniter Directory Helpers
|
| 20 | *
|
| 21 | * @package CodeIgniter
|
| 22 | * @subpackage Helpers
|
| 23 | * @category Helpers
|
| 24 | * @author Rick Ellis
|
| 25 | * @link http://www.codeigniter.com/user_guide/helpers/directory_helper.html
|
| 26 | */
|
| 27 |
|
| 28 | // ------------------------------------------------------------------------
|
| 29 |
|
| 30 | /**
|
| 31 | * Create a Directory Map
|
| 32 | *
|
| 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.
|
| 36 | *
|
| 37 | * @access public
|
| 38 | * @param string path to source
|
| 39 | * @param bool whether to limit the result to the top level only
|
| 40 | * @return array
|
| 41 | */
|
| 42 | function directory_map($source_dir, $top_level_only = FALSE)
|
| 43 | {
|
| 44 | if ($fp = @opendir($source_dir))
|
| 45 | {
|
| 46 | $filedata = array();
|
| 47 | while (FALSE !== ($file = readdir($fp)))
|
| 48 | {
|
| 49 | if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE)
|
| 50 | {
|
| 51 | $temp_array = array();
|
| 52 |
|
| 53 | $temp_array = directory_map($source_dir.$file."/");
|
| 54 |
|
| 55 | $filedata[$file] = $temp_array;
|
| 56 | }
|
| 57 | elseif (substr($file, 0, 1) != ".")
|
| 58 | {
|
| 59 | $filedata[] = $file;
|
| 60 | }
|
| 61 | }
|
| 62 | return $filedata;
|
| 63 | }
|
| 64 | }
|
| 65 |
|
| 66 |
|
admin | b0dd10f | 2006-08-25 17:25:49 +0000 | [diff] [blame] | 67 | ?> |