add ExecCmd and Tempdir
[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.%s", sys_get_temp_dir(), $prefix, uniqid());
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 }