stream_read function for registered wrapper class.
| From: | Rob | Date: | Wed, 19 Sep 2012 16:43:03 +0000 |
| Subject: | stream_read function for registered wrapper class. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-319144@lists.php.net to get a copy of this message | ||
I have a very large XML file that I have to process. It's about 7 GB.
Some of the individual elements that I need are larger than 8192 bytes.
I'm trying to write a Stream wrapper class to give me a specific element
at a time, but I keep running into issues with the stream wrapper and
fread, stream_get_content functions.
fread will never return more than 8192 bytes (is that a bug?), so I can't
use that at all. When I use stream_get_content, and pass in 16384, weird
things happen in my stream_read method. If I return 16384 bytes, it gets
truncated to 8192, and the stream_read method is called again and again,
until the total returned is 16384. Normally, stream_read is called twice
in this case (since it "returns" 8192 both times).
This really screws up what I'm trying to do with this stream wrapper.
Admittedly, I don't know much about stream wrappers. This is my first
one, and I can't find much relevant documentation on them. But it
doesn't seem like it's working correctly to me. If I ask for 16384 bytes
with fread, shouldn't it give me 16384 bytes? And if I return 16384
bytes when I use stream_get_contents, shouldn't it return 16384 bytes the
first time?
Thanks for any help.
-- Rob