Hi,
Recently I wrote this class and hope that this function will be
included in JFolder class as an alternative of files
This function is faster, because it doesn't call preg_match and asort
functions and doesn't go deeper than specified folders in exclude list
/**
* JFolder extension class
*
*/
class JFolderWCP {
/**
* Utility function to read the files in a folder.
*
* @param string The full path of the folder to read
* @param array The exclude list
* @return array Files and folders in the given folder
* @access public
*/
function files($path, $exclude = array('.svn', 'CVS')) {
// Initialize variables
$arr = array();
// read the source directory
$handle = opendir($path);
while(($file = readdir($handle)) !== false) {
if($file != '.' and $file != '..' and !in_array($file,
$exclude)) {
$dir = $path . DS . $file;
if(!in_array($dir, $exclude)) {
if(is_dir($dir))
$arr = array_merge($arr, JFolderWCP::files
($dir, $exclude));
else
$arr[] = $dir;
}
}
}
closedir($handle);
return $arr;
}
}
Regards,
Edvard
On Jun 16, 1:49 am, nicolas <
nicowis...@gmail.com> wrote:
> Hi,
>
> I think I've found a small issue in the functions Jfolder::files and
> JFolder::folders in the 1.5.x versions of Joomla so I submitted a
> report on the bug tracker. Elin Waring redirected me here, as it would
> be most suitable for 1.6 release.
>
> Here's the report I've made:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEd...