gnu-social/extlib/get_temp_dir.php
CiaranG 537819ba8a Add a sys_get_temp_dir substitute to extlib for easier installation on versions that lack it
darcs-hash:20080924150828-f6e2c-4c592c60b7ff6b0cae5a222a5d871fc875217e13.gz
2008-09-24 11:08:28 -04:00

15 lines
431 B
PHP

<?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));
}
}
?>