From: Michael Wallner Date: Sat, 28 Mar 2015 10:58:10 +0000 (+0100) Subject: private tempnames X-Git-Tag: v3.0.0~9 X-Git-Url: https://git.m6w6.name/?p=pharext%2Fpharext;a=commitdiff_plain;h=b632c5fcceda2e2b1cda995e34a34708e3a87ce0 private tempnames --- diff --git a/src/pharext/Tempname.php b/src/pharext/Tempname.php index b5e7520..d46250f 100644 --- a/src/pharext/Tempname.php +++ b/src/pharext/Tempname.php @@ -2,6 +2,8 @@ namespace pharext; +use pharext\Exception; + /** * A temporary file/directory name */ @@ -17,7 +19,11 @@ class Tempname * @param string $suffix e.g. file extension */ public function __construct($prefix, $suffix = null) { - $this->name = sys_get_temp_dir() . "/" . uniqid($prefix) . $suffix; + $temp = sys_get_temp_dir() . "/pharext-" . posix_getlogin(); + if (!is_dir($temp) && !mkdir($temp, 0700, true)) { + throw new Exception; + } + $this->name = $temp ."/". uniqid($prefix) . $suffix; } /**