diff options
author | Bharat Mediratta <bharat@menalto.com> | 2011-08-27 20:56:03 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2011-08-27 20:56:03 -0700 |
commit | 084c2717c0ddff6c5caa79c62abb3cdb9b4aea31 (patch) | |
tree | af0fc03f042d11715cbbb3d137390d7df706ec3c /modules/gallery/helpers/system.php | |
parent | dc21cf36b606048dc24532407d39bc8f5b4211fa (diff) | |
parent | 246f5b59cb0e525a5ff6eaffce6b13e9af7e70b2 (diff) |
Merge branch 'master' into bharat_dev
Diffstat (limited to 'modules/gallery/helpers/system.php')
-rw-r--r-- | modules/gallery/helpers/system.php | 21 |
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 |