diff options
author | admin <devnull@localhost> | 2006-10-23 22:49:27 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-10-23 22:49:27 +0200 |
commit | c1e23ce329575d2777dc1c87b87c4b1171c4e18b (patch) | |
tree | fe5fd5137350edb2914d8645dd07219d3c38f7cd /system/helpers/file_helper.php | |
parent | e85c05d6999e07b19d4691b81e0680c4e56973a8 (diff) |
Diffstat (limited to 'system/helpers/file_helper.php')
-rw-r--r-- | system/helpers/file_helper.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php index c9c21380d..4da62ade6 100644 --- a/system/helpers/file_helper.php +++ b/system/helpers/file_helper.php @@ -141,5 +141,39 @@ function delete_files($path, $del_dir = FALSE, $level = 0) } } +// ------------------------------------------------------------------------ + +/** + * Get Filenames + * + * Reads the specified directory and builds an array containing the filenames. + * Any sub-folders contained within the specified path are read as well. + * + * @access public + * @param string path to source + * @param bool whether to include the path as part of the filename + * @return array + */ +function get_filenames($source_dir, $include_path = FALSE) +{ + static $_filedata = array(); + + if ($fp = @opendir($source_dir)) + { + while (FALSE !== ($file = readdir($fp))) + { + if (@is_dir($source_dir.$file) && substr($file, 0, 1) != '.') + { + get_filenames($source_dir.$file."/", $include_path); + } + elseif (substr($file, 0, 1) != ".") + { + + $_filedata[] = ($include_path == TRUE) ? $source_dir.$file : $file; + } + } + return $_filedata; + } +} ?>
\ No newline at end of file |