Add a sys_get_temp_dir substitute to extlib for easier installation on versions that lack it

darcs-hash:20080924150828-f6e2c-4c592c60b7ff6b0cae5a222a5d871fc875217e13.gz
This commit is contained in:
CiaranG 2008-09-24 11:08:28 -04:00
parent ca4f358362
commit 537819ba8a
1 changed files with 14 additions and 0 deletions

14
extlib/get_temp_dir.php Normal file
View File

@ -0,0 +1,14 @@
<?php
if ( !function_exists('sys_get_temp_dir')) {
function sys_get_temp_dir() {
if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
$tempfile=tempnam(uniqid(rand(),TRUE),'');
if (file_exists($tempfile)) {
unlink($tempfile);
}
return realpath(dirname($tempfile));
}
}
?>