Skip to content

Commit

Permalink
* added System::tmpdir() method (now uses SystemRoot env.var on Windows)
Browse files Browse the repository at this point in the history
  • Loading branch information
stigsb committed Dec 26, 2001
1 parent abe6f2a commit 6b8397b
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions pear/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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';
}
}
?>

0 comments on commit 6b8397b

Please sign in to comment.