File:
[ELWIX - Embedded LightWeight unIX -] /
embedaddon /
php /
ext /
standard /
tests /
file /
bug27508.phpt
Revision
1.1.1.1 (vendor branch):
download - view:
text,
annotated -
select for diffs -
revision graph
Tue Feb 21 23:48:03 2012 UTC (12 years, 8 months ago) by
misho
Branches:
php,
MAIN
CVS tags:
v5_4_3elwix,
v5_4_29p0,
v5_4_29,
v5_4_20p0,
v5_4_20,
v5_4_17p0,
v5_4_17,
v5_3_10,
HEAD
php
--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()
{
if (!$this->fp) {
return true;
}
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");
$tmp_dir = __DIR__;
$tn = (binary) tempnam($tmp_dir, 'foo');
if (!$tn) {
die("tempnam failed");
}
$fp = fopen("myFile://" . urlencode($tn), "w+");
if (!$fp) {
die("fopen failed");
}
fwrite($fp, b"line1\n");
fwrite($fp, b"line2\n");
fwrite($fp, b"line3\n");
debug_zval_dump(feof($fp));
rewind($fp);
echo ftell($fp) . "\n";
debug_zval_dump(feof($fp));
while ($fp && !feof($fp)) {
echo fgets($fp);
}
fclose($fp);
unlink($tn);
?>
--EXPECT--
bool(false) refcount(1)
0
bool(false) refcount(1)
line1
line2
line3
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>