directory_helper.php
Go to the documentation of this file.00001 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 if ( ! function_exists('directory_map'))
00043 {
00044 function directory_map($source_dir, $top_level_only = FALSE)
00045 {
00046 if ($fp = @opendir($source_dir))
00047 {
00048 $source_dir = rtrim($source_dir, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
00049 $filedata = array();
00050
00051 while (FALSE !== ($file = readdir($fp)))
00052 {
00053 if (strncmp($file, '.', 1) == 0)
00054 {
00055 continue;
00056 }
00057
00058 if ($top_level_only == FALSE && @is_dir($source_dir.$file))
00059 {
00060 $temp_array = array();
00061
00062 $temp_array = directory_map($source_dir.$file.DIRECTORY_SEPARATOR);
00063
00064 $filedata[$file] = $temp_array;
00065 }
00066 else
00067 {
00068 $filedata[] = $file;
00069 }
00070 }
00071
00072 closedir($fp);
00073 return $filedata;
00074 }
00075 }
00076 }
00077
00078
00079
00080