diff options
author | Thomas Willingham <beardyunixer@beardyunixer.com> | 2014-12-11 20:15:27 +0000 |
---|---|---|
committer | Thomas Willingham <beardyunixer@beardyunixer.com> | 2014-12-11 20:15:27 +0000 |
commit | 967ab871b836f618107fe144978bd1453c3c6634 (patch) | |
tree | 1bcb1b4bb1b25c904a2bc06f5c6d526d29909eaa /library/Smarty/libs/sysplugins/smarty_internal_write_file.php | |
parent | 960c35bad3a0dbaa7a1f2191aef60ad014d926ca (diff) | |
download | volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.tar.gz volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.tar.bz2 volse-hubzilla-967ab871b836f618107fe144978bd1453c3c6634.zip |
Update Smarty
Diffstat (limited to 'library/Smarty/libs/sysplugins/smarty_internal_write_file.php')
-rw-r--r-- | library/Smarty/libs/sysplugins/smarty_internal_write_file.php | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_write_file.php b/library/Smarty/libs/sysplugins/smarty_internal_write_file.php index e5d19ce8d..f46fe2b6c 100644 --- a/library/Smarty/libs/sysplugins/smarty_internal_write_file.php +++ b/library/Smarty/libs/sysplugins/smarty_internal_write_file.php @@ -2,25 +2,27 @@ /** * Smarty write file plugin * - * @package Smarty + * @package Smarty * @subpackage PluginsInternal - * @author Monte Ohrt + * @author Monte Ohrt */ /** * Smarty Internal Write File Class * - * @package Smarty + * @package Smarty * @subpackage PluginsInternal */ -class Smarty_Internal_Write_File { - +class Smarty_Internal_Write_File +{ /** * Writes file in a safe way to disk * - * @param string $_filepath complete filepath - * @param string $_contents file content - * @param Smarty $smarty smarty instance + * @param string $_filepath complete filepath + * @param string $_contents file content + * @param Smarty $smarty smarty instance + * + * @throws SmartyException * @return boolean true */ public static function writeFile($_filepath, $_contents, Smarty $smarty) @@ -38,17 +40,16 @@ class Smarty_Internal_Write_File { } // write to tmp file, then move to overt file lock race condition - $_tmp_file = $_dirpath . DS . uniqid('wrt', true); + $_tmp_file = $_dirpath . DS . str_replace(array('.', ','), '_', uniqid('wrt', true)); if (!file_put_contents($_tmp_file, $_contents)) { error_reporting($_error_reporting); throw new SmartyException("unable to write file {$_tmp_file}"); - return false; - } - + } + /* * Windows' rename() fails if the destination exists, * Linux' rename() properly handles the overwrite. - * Simply unlink()ing a file might cause other processes + * Simply unlink()ing a file might cause other processes * currently reading that file to fail, but linux' rename() * seems to be smart enough to handle that for us. */ @@ -71,7 +72,6 @@ class Smarty_Internal_Write_File { if (!$success) { error_reporting($_error_reporting); throw new SmartyException("unable to write file {$_filepath}"); - return false; } if ($smarty->_file_perms !== null) { @@ -80,9 +80,7 @@ class Smarty_Internal_Write_File { umask($old_umask); } error_reporting($_error_reporting); + return true; } - } - -?>
\ No newline at end of file |