5 class Tempfile
extends \SplFileInfo
9 function __construct($prefix) {
11 $template = sys_get_temp_dir()."/$prefix.";
15 $path = $template.uniqid();
16 $this->handle
= fopen($path, "x");
17 } while (!is_resource($this->handle
) && $tries++
< 10);
20 if (!is_resource($this->handle
)) {
21 throw new \
Exception("Could not create temporary file");
24 parent
::__construct($path);
27 function __destruct() {
28 @unlink
($this->getPathname());
31 function closeStream() {
32 fclose($this->handle
);
35 function getStream() {