cvs: php4 /pear System.php

From: Date: Wed, 26 Dec 2001 01:23:04 +0000
Subject: cvs: php4 /pear System.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1684@lists.php.net to get a copy of this message
ssb Tue Dec 25 20:23:04 2001 EDT Modified files: /php4/pear System.php Log: * added System::tmpdir() method (now uses SystemRoot env.var on Windows) Index: php4/pear/System.php diff -u php4/pear/System.php:1.5 php4/pear/System.php:1.6 --- php4/pear/System.php:1.5 Tue Dec 18 12:06:28 2001 +++ php4/pear/System.php Tue Dec 25 20:23:04 2001 @@ -17,7 +17,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: System.php,v 1.5 2001/12/18 17:06:28 mj Exp $ +// $Id: System.php,v 1.6 2001/12/26 01:23:04 ssb Exp $ // // TODO: @@ -41,7 +41,7 @@ * * @package System * @author Tomas V.V.Cox <cox@idecnet.com> -* @version $Revision: 1.5 $ +* @version $Revision: 1.6 $ * @access public */ class System extends PEAR @@ -316,15 +316,8 @@ } //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 @@ 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'; + } } ?>

« previous php.pear.cvs (#1684) next »