Crisis.Ionic.Zip.ZipEntry.PrepOutputStream C# (CSharp) Метод

PrepOutputStream() приватный Метод

Prepare the given stream for output - wrap it in a CountingStream, and then in a CRC stream, and an encryptor and deflator as appropriate.

Previously this was used in ZipEntry.Write(), but in an effort to introduce some efficiencies in that method I've refactored to put the code inline. This method still gets called by ZipOutputStream.

private PrepOutputStream ( Stream s, long streamLength, CountingStream &outputCounter, Stream &encryptor, Stream &compressor, Crisis &output ) : void
s Stream
streamLength long
outputCounter CountingStream
encryptor Stream
compressor Stream
output Crisis
Результат void
        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);
        }
ZipEntry