5 class Tempfile
extends \SplFileInfo
9 function __construct($prefix) {
11 /* PharData needs a dot in the filename, sure */
12 $temp = sys_get_temp_dir() . "/";
16 $path = $temp.uniqid($prefix).".tmp";
17 $this->handle
= fopen($path, "x");
18 } while (!is_resource($this->handle
) && $tries++
< 10);
21 if (!is_resource($this->handle
)) {
22 throw new \
Exception("Could not create temporary file");
25 parent
::__construct($path);
28 function __destruct() {
29 @unlink
($this->getPathname());
32 function closeStream() {
33 fclose($this->handle
);
36 function getStream() {