internal void PrepOutputStream(Stream s,
long streamLength,
out CountingStream outputCounter,
out Stream encryptor,
out Stream compressor,
out Crisis.Ionic.Crc.CrcCalculatorStream output)
{
TraceWriteLine("PrepOutputStream: e({0}) comp({1}) crypto({2}) zf({3})",
FileName,
CompressionLevel,
Encryption,
_container.Name);
// Wrap a counting stream around the raw output stream:
// This is the last thing that happens before the bits go to the
// application-provided stream.
outputCounter = new CountingStream(s);
// Sometimes the incoming "raw" output stream is already a CountingStream.
// Doesn't matter. Wrap it with a counter anyway. We need to count at both
// levels.
if (streamLength != 0L)
{
// Maybe wrap an encrypting stream around that:
// This will happen BEFORE output counting, and AFTER deflation, if encryption
// is used.
encryptor = MaybeApplyEncryption(outputCounter);
// Maybe wrap a compressing Stream around that.
// This will happen BEFORE encryption (if any) as we write data out.
compressor = MaybeApplyCompression(encryptor, streamLength);
}
else
{
encryptor = compressor = outputCounter;
}
// Wrap a CrcCalculatorStream around that.
// This will happen BEFORE compression (if any) as we write data out.
output = new Crisis.Ionic.Crc.CrcCalculatorStream(compressor, true);
}