From 6b8397b9f754c96114129a8e8a1d1633de578c03 Mon Sep 17 00:00:00 2001 From: Stig Bakken Date: Wed, 26 Dec 2001 01:23:04 +0000 Subject: [PATCH] * added System::tmpdir() method (now uses SystemRoot env.var on Windows) --- pear/System.php | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/pear/System.php b/pear/System.php index 2f030b416779d..d3c56d0697b5b 100644 --- a/pear/System.php +++ b/pear/System.php @@ -316,15 +316,8 @@ function mktemp($args = null) } //print_r($opts); $prefix = (isset($opts[1][0])) ? $opts[1][0] : 'tmp'; - if(!isset($tmpdir)) { - if (OS_WINDOWS){ - $tmpdir = getenv('TMP'); - } else { - $tmpdir = getenv('TMPDIR'); - } - if (empty($tmpdir)) { - $tmpdir = (OS_WINDOWS) ? 'c:\\windows\\temp' : '/tmp'; - } + if (!isset($tmpdir)) { + $tmpdir = System::tmpdir(); } System::mkDir("-p $tmpdir"); $tmp = tempnam($tmpdir, $prefix); @@ -337,5 +330,21 @@ function mktemp($args = null) return $tmp; } + function tmpdir() + { + if (OS_WINDOWS){ + if (isset($_ENV['TEMP'])) { + return $_ENV['TEMP']; + } + if (isset($_ENV['TMP'])) { + return $_ENV['TMP']; + } + return $_ENV['SystemRoot'] . '\temp'; + } + if (isset($_ENV['TMPDIR'])) { + return $_ENV['TMPDIR']; + } + return '/tmp'; + } } ?> \ No newline at end of file