- don't use /tmp as tmpdir and avoid endless loop when fopen or tmpnam failed

This commit is contained in:
Pierre Joye 2008-08-18 21:24:52 +00:00
parent c89c62047c
commit 80d020011c

View File

@ -42,9 +42,16 @@ class FileStream {
stream_wrapper_register("myFile", "FileStream")
or die("Failed to register protocol");
$tn = tempnam('/tmp', 'foo');
$tmp_dir = __DIR__;
$tn = tempnam($tmp_dir, 'foo');
if (!$tn) {
die("tempnam failed");
}
$fp = fopen("myFile://" . urlencode($tn), "w+");
if (!$fp) {
die("fopen failed");
}
fwrite($fp, "line1\n");
fwrite($fp, "line2\n");