From 560efb353a1395f51a170f32b974c2afb897a712 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Thu, 27 Mar 2008 16:07:00 +0000 Subject: Fixed bug #4350 in get_filenames() when the $source_dir does not include a trailing slash --- system/helpers/file_helper.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index 1b37af2fd..7eb93dab2 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -160,19 +160,23 @@ if (! function_exists('delete_files')) * @access public * @param string path to source * @param bool whether to include the path as part of the filename + * @param bool internal variable to determine recursion status - do not use in calls * @return array */ if (! function_exists('get_filenames')) { - function get_filenames($source_dir, $include_path = FALSE, $recursion = FALSE) + function get_filenames($source_dir, $include_path = FALSE, $_recursion = FALSE) { static $_filedata = array(); - if ($recursion === FALSE) + // reset the array and make sure $source_dir has a trailing slash on the initial call + if ($_recursion === FALSE) { $_filedata = array(); + $source_dir = realpath($source_dir).'/'; } + if ($fp = @opendir($source_dir)) { while (FALSE !== ($file = readdir($fp))) -- cgit v1.2.3-24-g4f1b