summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/system.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2011-08-27 20:56:03 -0700
committerBharat Mediratta <bharat@menalto.com>2011-08-27 20:56:03 -0700
commit084c2717c0ddff6c5caa79c62abb3cdb9b4aea31 (patch)
treeaf0fc03f042d11715cbbb3d137390d7df706ec3c /modules/gallery/helpers/system.php
parentdc21cf36b606048dc24532407d39bc8f5b4211fa (diff)
parent246f5b59cb0e525a5ff6eaffce6b13e9af7e70b2 (diff)
Merge branch 'master' into bharat_dev
Diffstat (limited to 'modules/gallery/helpers/system.php')
-rw-r--r--modules/gallery/helpers/system.php21
1 files changed, 21 insertions, 0 deletions
diff --git a/modules/gallery/helpers/system.php b/modules/gallery/helpers/system.php
index c39c7227..4110b4ed 100644
--- a/modules/gallery/helpers/system.php
+++ b/modules/gallery/helpers/system.php
@@ -40,4 +40,25 @@ class system_Core {
}
return null;
}
+
+ /**
+ * Create a file with a unique file name.
+ * This helper is similar to the built-in tempnam.
+ * It allows the caller to specify a prefix and an extension.
+ * It always places the file in TMPPATH.
+ */
+ static function temp_filename($prefix="", $extension="") {
+ do {
+ $basename = tempnam(TMPPATH, $prefix);
+ if (!$basename) {
+ return false;
+ }
+ $filename = "$basename.$extension";
+ $success = !file_exists($filename) && @rename($basename, $filename);
+ if (!$success) {
+ @unlink($basename);
+ }
+ } while (!$success);
+ return $filename;
+ }
} \ No newline at end of file