summaryrefslogtreecommitdiff
path: root/pear/System.php
diff options
context:
space:
mode:
authorStig Bakken <ssb@php.net>2001-12-26 01:23:04 +0000
committerStig Bakken <ssb@php.net>2001-12-26 01:23:04 +0000
commit6b8397b9f754c96114129a8e8a1d1633de578c03 (patch)
treec0e1c00050f8f130edac83b1879baaa25c66142d /pear/System.php
parentabe6f2a233bc39f2f14ce8203c69280866783852 (diff)
downloadphp-git-6b8397b9f754c96114129a8e8a1d1633de578c03.tar.gz
* added System::tmpdir() method (now uses SystemRoot env.var on Windows)
Diffstat (limited to 'pear/System.php')
-rw-r--r--pear/System.php27
1 files changed, 18 insertions, 9 deletions
diff --git a/pear/System.php b/pear/System.php
index 2f030b4167..d3c56d0697 100644
--- a/pear/System.php
+++ b/pear/System.php
@@ -316,15 +316,8 @@ class System extends PEAR
}
//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 @@ class System extends PEAR
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