summaryrefslogtreecommitdiff
path: root/extlib/get_temp_dir.php
diff options
context:
space:
mode:
authorCiaranG <ciaran@ciarang.com>2008-09-24 11:08:28 -0400
committerCiaranG <ciaran@ciarang.com>2008-09-24 11:08:28 -0400
commit537819ba8a05cacdf1d56cd4ea8e1df9bfe5f2d0 (patch)
tree314e1ffe35156f1f01e2723ccfa557fabaad8964 /extlib/get_temp_dir.php
parentca4f358362e065a250f6b636fb847927219b95d1 (diff)
Add a sys_get_temp_dir substitute to extlib for easier installation on versions that lack it
darcs-hash:20080924150828-f6e2c-4c592c60b7ff6b0cae5a222a5d871fc875217e13.gz
Diffstat (limited to 'extlib/get_temp_dir.php')
-rw-r--r--extlib/get_temp_dir.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/extlib/get_temp_dir.php b/extlib/get_temp_dir.php
new file mode 100644
index 000000000..4ec96e522
--- /dev/null
+++ b/extlib/get_temp_dir.php
@@ -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));
+ }
+}
+?>