streams seek and feof()

From: Date: Sun, 01 Jan 2006 00:27:45 +0000
Subject: streams seek and feof()
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-3370@lists.php.net to get a copy of this message
Hi all, I am trying to figure out how streams seek/eof is supposed to work for pecl/phar, and have run up against a roadblock. Basically, the userspace implementation in pear/PHP_Archive will return true for feof() if you seek to the end of a file internal to a phar. pecl/phar will not, and I actually don't see any way to make it do so. Currently, the seek function can either return 0 or something else, and if you return 0, stream->eof is automatically set to 0 no matter what (inside main/streams/streams.c). if you return -1, then stream_seek returns -1, which tells PHP that the seek failed. This in turn sets the internal file pointer to bool(false) In other words, fseek($fp, filesize('phar://blah.phar/test.php')); var_dump(feof($fp), ftell($fp)); returns bool(true) int "43" for the userspace stream, and bool(false) int "43" for the extension, whereas seeking to filesize + 1 sets both to false in the pecl/phar, and set to true/44 in the userspace implementation. This is unacceptable, to say the least. How can I tell it that we are at the end of the stream *and* return a successful seek?? Thanks, Greg

« previous php.pecl.dev (#3370) next »