(C) 1998 AROS - The Amiga Research OS
Write: Write the supplied id, size and evt type into the stream.
Read: Get a chunk from disk
For Write mode there are som problems with unknown chunk size and non-random-seekable streams: 4. situations:
SIZE KNOWN && RSEEK - Just write the whole header. SIZE KNOWN && !RSEEK - Write whole header. No RSEEK does not matter, since we don't have to seek back to write size in PopChunk
SIZE UNKNOWN && RSEEK - Write whole header. Write size too, just to seek pass it, even if the size value might be meaningless. We will seek back and insert the correct size later.
SIZE UNKNOWN && !RSEEK - Here is where the trouble starts. We can not seek back and insert the correct size later, which means that we MUST buffer the contents of the chunk, and don't write ANYTHING to the stream until we know its size.
We preserve the old StreamHandler, and inserts a new one that buffers all writes into memory.
Added lots of debug output