Jfolder::files and JFolder::folders and $exclude

55 views
Skip to first unread message

nicolas

unread,
Jun 15, 2009, 4:49:51 PM6/15/09
to Joomla! Framework Development
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=TrackerItemEdit&tracker_id=32&tracker_item_id=16809
Basically, It's just adding the $exclude variable to the recursive
calls of those two functions so that its value is propagated.

edo888

unread,
Jul 14, 2009, 2:18:39 AM7/14/09
to Joomla! Framework Development
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...
Reply all
Reply to author
Forward
0 new messages