views:

25

answers:

1

A decompression API that I am using has the following API:

Decode(Stream inStream,Stream outStream)

I'd like to create a wrapper around this API, such that I can create my own Stream class which offers up the decoded data.

Stream decodedStream=new BlaDecodeStream(inStream);

So that I can than use this stream as a parameter to the XmlReader constructor in the same way one might use the System.IO.Compression.GZipStream. As far as I can tell, the only other option is set outStream stream to a MemoryStream or to a FileStream and go in two hops. The files I am dealing with are enormous, so neither of these options are particularly attractive.

Before I go reinventing the wheel, is there any prior art that I might be able to draw from, or something in the BCL I might have missed? The CircularStream implementation here would go some of the way to helping, but I'm really looking for something similar that would block (as opposed to over/underrun) when the Stream's internal buffer is 'empty' when reading from it and block when the internal buffer is full when writing to it.

In this way it could serve as parameter outStream and simultaneously (i.e. from another thread) could be read from by the XmlReader.

+1  A: 

I asked about a blocking stream reader a while ago. I implemented one of the suggestions and it works fine.

Don Kirkby