Better recognize Windows filesystems to reduce warnings

This commit is contained in:
boots
2007-01-10 16:28:38 +00:00
parent aae3f2e702
commit f30371dff9
2 changed files with 7 additions and 2 deletions

3
NEWS
View File

@@ -1,4 +1,5 @@
- emulate %R in the date_format modifier on windows (Danilo Buerger, boots)
- update smarty_core_write_file() to better recognize Windows (boots)
- emulate %R in the date_format modifier on Windows (Danilo Buerger, boots)
Version 2.6.16 (Dec 1st, 2006)
-------------------------------

View File

@@ -15,6 +15,10 @@
*/
function smarty_core_write_file($params, &$smarty)
{
static $OS;
if (is_null($OS)) {
$OS = substr(PHP_OS,0,3);
}
$_dirname = dirname($params['filename']);
if ($params['create_dirs']) {
@@ -37,7 +41,7 @@ function smarty_core_write_file($params, &$smarty)
fwrite($fd, $params['contents']);
fclose($fd);
if (PHP_OS == 'Windows' || !@rename($_tmp_file, $params['filename'])) {
if ($OS == 'WIN' || !@rename($_tmp_file, $params['filename'])) {
// On platforms and filesystems that cannot overwrite with rename()
// delete the file before renaming it -- because windows always suffers
// this, it is short-circuited to avoid the initial rename() attempt