2de174dfc8272889ab2d57677b7ea984eeaa39e5
[pharext/pharext] / src / pharext / Tempdir.php
1 <?php
2
3 namespace pharext;
4
5 class Tempdir extends \SplFileInfo
6 {
7 private $dir;
8
9 public function __construct($prefix) {
10 $temp = sprintf("%s/%s", sys_get_temp_dir(), uniqid($prefix));
11 if (!is_dir($temp)) {
12 if (!mkdir($temp, 0700, true)) {
13 throw new Exception("Could not create tempdir: ".error_get_last()["message"]);
14 }
15 }
16 parent::__construct($temp);
17 }
18 }