summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2009-11-27 19:00:20 +0100
committerDerek Jones <derek.jones@ellislab.com>2009-11-27 19:00:20 +0100
commit788b00f7eaad969120079acedc82e8d60b0e2a46 (patch)
treefe7e91590e76a4a27b5aaefdda45e9180f56366e /system/helpers
parentde27adfa84600ea863e8737d60861991ff2bbb62 (diff)
non-backwards compatible change to get_dir_file_info() for performance reasons, as well as fixing recursive bug
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/file_helper.php14
1 files changed, 8 insertions, 6 deletions
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index cb3d60ee9..41ec2648e 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -220,7 +220,7 @@ if ( ! function_exists('get_filenames'))
*/
if ( ! function_exists('get_dir_file_info'))
{
- function get_dir_file_info($source_dir, $include_path = FALSE, $_recursion = FALSE)
+ function get_dir_file_info($source_dir, $top_level_only = TRUE, $_recursion = FALSE)
{
static $_filedata = array();
$relative_path = $source_dir;
@@ -234,18 +234,20 @@ if ( ! function_exists('get_dir_file_info'))
$source_dir = rtrim(realpath($source_dir), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR;
}
+ // foreach (scandir($source_dir, 1) as $file) // In addition to being PHP5+, scandir() is simply not as fast
while (FALSE !== ($file = readdir($fp)))
{
- if (@is_dir($source_dir.$file) && strncmp($file, '.', 1) !== 0)
- {
- get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $include_path, TRUE);
- }
- elseif (strncmp($file, '.', 1) !== 0)
+ if (@is_dir($source_dir.$file) AND strncmp($file, '.', 1) !== 0 AND $top_level_only === FALSE)
{
+ get_dir_file_info($source_dir.$file.DIRECTORY_SEPARATOR, $top_level_only, TRUE);
+ }
+ elseif (strncmp($file, '.', 1) !== 0)
+ {
$_filedata[$file] = get_file_info($source_dir.$file);
$_filedata[$file]['relative_path'] = $relative_path;
}
}
+
return $_filedata;
}
else