You are here

function smarty_core_rmdir in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle/lib/smarty/core/core.rmdir.php \smarty_core_rmdir()
1 call to smarty_core_rmdir()
smarty_core_rm_auto in includes/moodle/lib/smarty/core/core.rm_auto.php

File

includes/moodle/lib/smarty/core/core.rmdir.php, line 20

Code

function smarty_core_rmdir($params, &$smarty) {
  if (!isset($params['level'])) {
    $params['level'] = 1;
  }
  if (!isset($params['exp_time'])) {
    $params['exp_time'] = null;
  }
  if ($_handle = @opendir($params['dirname'])) {
    while (false !== ($_entry = readdir($_handle))) {
      if ($_entry != '.' && $_entry != '..') {
        if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
          $_params = array(
            'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
            'level' => $params['level'] + 1,
            'exp_time' => $params['exp_time'],
          );
          require_once SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php';
          smarty_core_rmdir($_params, $smarty);
        }
        else {
          $smarty
            ->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
        }
      }
    }
    closedir($_handle);
  }
  if ($params['level']) {
    return @rmdir($params['dirname']);
  }
  return (bool) $_handle;
}