X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FTempname.php;h=d46250f7472b379e44ea17f98355af06d2f83eab;hb=b632c5fcceda2e2b1cda995e34a34708e3a87ce0;hp=b5e7520284f864a594937b7867104fb79c7716ce;hpb=19ed5a5524fc2a2ed31e6c264ffbd0250027982d;p=pharext%2Fpharext 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; } /**