]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Add a sys_get_temp_dir substitute to extlib for easier installation on versions that...
authorCiaranG <ciaran@ciarang.com>
Wed, 24 Sep 2008 15:08:28 +0000 (11:08 -0400)
committerCiaranG <ciaran@ciarang.com>
Wed, 24 Sep 2008 15:08:28 +0000 (11:08 -0400)
darcs-hash:20080924150828-f6e2c-4c592c60b7ff6b0cae5a222a5d871fc875217e13.gz

extlib/get_temp_dir.php [new file with mode: 0644]

diff --git a/extlib/get_temp_dir.php b/extlib/get_temp_dir.php
new file mode 100644 (file)
index 0000000..4ec96e5
--- /dev/null
@@ -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));
+       }
+}
+?>