X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FTempfile.php;fp=src%2Fpharext%2FTempfile.php;h=13ac411af246ae2fe19e4d120a8bc2ab3ccfc14c;hb=02e746254e0800bff88c45d41463bdb0b3aa69db;hp=0000000000000000000000000000000000000000;hpb=ff5a1f3252689c2c473ef89ab025667ae3b23b16;p=pharext%2Fpharext diff --git a/src/pharext/Tempfile.php b/src/pharext/Tempfile.php new file mode 100644 index 0000000..13ac411 --- /dev/null +++ b/src/pharext/Tempfile.php @@ -0,0 +1,38 @@ +handle = fopen($path, "x"); + } while (!is_resource($this->handle) && $tries++ < 10); + umask($omask); + + if (!is_resource($this->handle)) { + throw new \Exception("Could not create temporary file"); + } + + parent::__construct($path); + } + + function __destruct() { + @unlink($this->getPathname()); + } + + function closeStream() { + fclose($this->handle); + } + + function getStream() { + return $this->handle; + } +}