Marcus Boerger wrote: > The filters need an input state and an output state. And they need to > respect the the fact that number of requested bytes does not necessarily > mean reading the same amount of data on the other end. In fact the output > side does generally not know whether less, the same amount or more input is > to be read. But this can be dealt with inside the filter. However the > filters should return the number input vs the number of output filters > always independently. Regarding states we would be interested if reaching > EOD on the input state meant reaching EOD on the output side prior to the > requested amount, at the requested amount or not at all yet (more data > available).
Hi, All of this makes sense, but how to implement it? Currently, there is no clear way to answer questions like: 1) how much data did the filter consume, and how much is left over? 2) how much data is left in the original stream prior to filtering? Perhaps this could be implemented by overloading ftell() so that it can accept a filter resource as well as a stream resource? Also, a new function could be implemented: stream_filter_datasize(resource $filter) // I'm open to better names that would either return the total size of filtered data available, or false if this is indeterminate. This would allow: <?php $startoffile = 123; $a = fopen('blah.zip'); fseek($a, $startoffile); $filter = stream_filter_append($a, 'bzip2.decompress'); $b = fread($a, 170); echo ftell($a),", ",ftell($filter),", ",stream_filter_datasize($filter),"\n"; // outputs "145, 170, 176" ?> Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php