9 * delete a dir recursively (level=0 -> keep root)
10 * WARNING: no tests, it will try to remove what you tell it!
12 * @param string $dirname
13 * @param integer $level
14 * @param integer $exp_time
18 // $dirname, $level = 1, $exp_time = null
20 function smarty_core_rmdir($params, &$smarty)
22 if(!isset($params['level'])) { $params['level'] = 1; }
23 if(!isset($params['exp_time'])) { $params['exp_time'] = null; }
25 if($_handle = @opendir
($params['dirname'])) {
27 while (false !== ($_entry = readdir($_handle))) {
28 if ($_entry != '.' && $_entry != '..') {
29 if (@is_dir
($params['dirname'] . DIRECTORY_SEPARATOR
. $_entry)) {
31 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR
. $_entry,
32 'level' => $params['level'] +
1,
33 'exp_time' => $params['exp_time']
35 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.rmdir.php');
36 smarty_core_rmdir($_params, $smarty);
39 $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR
. $_entry, $params['exp_time']);
46 if ($params['level']) {
47 return @rmdir
($params['dirname']);
49 return (bool)$_handle;
53 /* vim: set expandtab: */