2005-05-11 02:01:44 +00:00
|
|
|
--TEST--
|
|
|
|
Bug #27508 (userspace wrappers have bogus eof indicator)
|
|
|
|
--FILE--
|
|
|
|
<?php # vim:ft=php
|
|
|
|
class FileStream {
|
|
|
|
public $fp;
|
|
|
|
|
|
|
|
function stream_open($path, $mode, $options, &$opened_path)
|
|
|
|
{
|
|
|
|
$url = urldecode(substr($path, 9));
|
|
|
|
$this->fp = fopen($url, $mode);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
function stream_read($count)
|
|
|
|
{
|
|
|
|
return fread($this->fp, $count);
|
|
|
|
}
|
|
|
|
|
|
|
|
function stream_write($data)
|
|
|
|
{
|
|
|
|
return fwrite($this->fp, $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
function stream_tell()
|
|
|
|
{
|
|
|
|
return ftell($this->fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
function stream_eof()
|
|
|
|
{
|
|
|
|
return feof($this->fp);
|
|
|
|
}
|
|
|
|
|
|
|
|
function stream_seek($offset, $whence)
|
|
|
|
{
|
|
|
|
return fseek($this->fp, $offset, $whence) == 0 ? true : false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stream_wrapper_register("myFile", "FileStream")
|
|
|
|
or die("Failed to register protocol");
|
|
|
|
|
2008-08-18 21:24:52 +00:00
|
|
|
$tmp_dir = __DIR__;
|
|
|
|
$tn = tempnam($tmp_dir, 'foo');
|
|
|
|
if (!$tn) {
|
|
|
|
die("tempnam failed");
|
|
|
|
}
|
2005-05-11 02:01:44 +00:00
|
|
|
|
|
|
|
$fp = fopen("myFile://" . urlencode($tn), "w+");
|
2008-08-18 21:24:52 +00:00
|
|
|
if (!$fp) {
|
|
|
|
die("fopen failed");
|
|
|
|
}
|
2005-05-11 02:01:44 +00:00
|
|
|
|
|
|
|
fwrite($fp, "line1\n");
|
|
|
|
fwrite($fp, "line2\n");
|
|
|
|
fwrite($fp, "line3\n");
|
|
|
|
|
|
|
|
debug_zval_dump(feof($fp));
|
|
|
|
rewind($fp);
|
|
|
|
echo ftell($fp) . "\n";
|
|
|
|
debug_zval_dump(feof($fp));
|
2007-02-21 22:08:08 +00:00
|
|
|
while ($fp && !feof($fp)) {
|
2005-05-11 02:01:44 +00:00
|
|
|
echo fgets($fp);
|
|
|
|
}
|
|
|
|
fclose($fp);
|
|
|
|
|
|
|
|
unlink($tn);
|
2007-02-21 22:08:08 +00:00
|
|
|
?>
|
2005-05-11 02:01:44 +00:00
|
|
|
--EXPECT--
|
|
|
|
bool(false) refcount(1)
|
|
|
|
0
|
|
|
|
bool(false) refcount(1)
|
|
|
|
line1
|
|
|
|
line2
|
|
|
|
line3
|