From f30371dff9c6831957ee467bde35ea4cfc37537e Mon Sep 17 00:00:00 2001 From: boots Date: Wed, 10 Jan 2007 16:28:38 +0000 Subject: [PATCH] Better recognize Windows filesystems to reduce warnings --- NEWS | 3 ++- libs/internals/core.write_file.php | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 6388b972..953294e9 100644 --- a/NEWS +++ b/NEWS @@ -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) ------------------------------- diff --git a/libs/internals/core.write_file.php b/libs/internals/core.write_file.php index 48a3b1a7..0afa5b54 100644 --- a/libs/internals/core.write_file.php +++ b/libs/internals/core.write_file.php @@ -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