18 $_dirname = dirname($params[
'filename']);
20 if ($params[
'create_dirs']) {
21 $_params = array(
'dir' => $_dirname);
22 require_once(SMARTY_CORE_DIR .
'core.create_dir_structure.php');
27 $_tmp_file = tempnam($_dirname,
'wrt');
29 if (!($fd = @fopen($_tmp_file,
'wb'))) {
31 if (!($fd = @fopen($_tmp_file,
'wb'))) {
32 $smarty->trigger_error(
"problem writing temporary file '$_tmp_file'");
37 fwrite($fd, $params[
'contents']);
44 @unlink($params[
'filename']);
45 @rename($_tmp_file, $params[
'filename']);
47 @chmod($params[
'filename'], $smarty->_file_perms);