blob: 69eb13d11c2229af1c339f8ed6bc39df949f075b [file] [log] [blame]
adminb0dd10f2006-08-25 17:25:49 +00001<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * Code Igniter
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, pMachine, 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 * Code Igniter 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 Direcotry 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 */
42function directory_map($source_dir, $top_level_only = FALSE)
43{
44 if ( ! isset($filedata))
45 $filedata = array();
46
47 if ($fp = @opendir($source_dir))
48 {
49 while (FALSE !== ($file = readdir($fp)))
50 {
51 if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.' AND $top_level_only == FALSE)
52 {
53 $temp_array = array();
54
55 $temp_array = directory_map($source_dir.$file."/");
56
57 $filedata[$file] = $temp_array;
58 }
59 elseif (substr($file, 0, 1) != ".")
60 {
61 $filedata[] = $file;
62 }
63 }
64 return $filedata;
65 }
66}
67
68
69?>