X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FTempdir.php;h=eb592637e5ea921640bdce316549c676a285217f;hb=861260c111bff72f60665393660b6f5375559510;hp=585033acfed92b92cfcd2065e1d967dc6b10c628;hpb=c8adc57c38cc535e0dcda979565b7639896e7370;p=pharext%2Fpharext diff --git a/src/pharext/Tempdir.php b/src/pharext/Tempdir.php index 585033a..eb59263 100644 --- a/src/pharext/Tempdir.php +++ b/src/pharext/Tempdir.php @@ -2,16 +2,19 @@ namespace pharext; +/** + * Create a temporary directory + */ class Tempdir extends \SplFileInfo { - private $dir; - + /** + * @param string $prefix prefix to uniqid() + * @throws \pharext\Exception + */ public function __construct($prefix) { - $temp = sprintf("%s/%s.%s", sys_get_temp_dir(), $prefix, uniqid()); - if (!is_dir($temp)) { - if (!mkdir($temp, 0700, true)) { - throw new Exception("Could not create tempdir: ".error_get_last()["message"]); - } + $temp = new Tempname($prefix); + if (!is_dir($temp) && !mkdir($temp, 0700, true)) { + throw new Exception("Could not create tempdir: ".error_get_last()["message"]); } parent::__construct($temp); }