internal void FinishOutputStream(Stream s, CountingStream entryCounter, Stream encryptor, Stream deflater, PMDCP.Compression.Zlib.CrcCalculatorStream output) { if (output == null) return; output.Close(); // by calling Close() on the deflate stream, we write the footer bytes, as necessary. if ((deflater as PMDCP.Compression.Zlib.DeflateStream) != null) deflater.Close(); #if !NETCF else if ((deflater as PMDCP.Compression.Zlib.ParallelDeflateOutputStream) != null) deflater.Close(); #endif encryptor.Flush(); encryptor.Close(); _LengthOfTrailer = 0; _UncompressedSize = output.TotalBytesSlurped; #if AESCRYPTO WinZipAesCipherStream wzacs = encryptor as WinZipAesCipherStream; if (wzacs != null && _UncompressedSize > 0) { s.Write(wzacs.FinalAuthentication, 0, 10); _LengthOfTrailer += 10; } #endif _CompressedFileDataSize = entryCounter.BytesWritten; _CompressedSize = _CompressedFileDataSize; // may be adjusted _Crc32 = output.Crc; // Set _RelativeOffsetOfLocalHeader now, to allow for re-streaming StoreRelativeOffset(); }
public WorkItem(int size, PMDCP.Compression.Zlib.CompressionLevel compressLevel, CompressionStrategy strategy) { buffer= new byte[size]; // alloc 5 bytes overhead for every block (margin of safety= 2) int n = size + ((size / 32768)+1) * 5 * 2; compressed= new byte[n]; status = (int)Status.None; compressor = new ZlibCodec(); compressor.InitializeDeflate(compressLevel, false); compressor.OutputBuffer = compressed; compressor.InputBuffer = buffer; }
void Updater_PackageInstallationComplete(object sender, PMDCP.Updater.PackageInstallationCompleteEventArgs e) { packageScroller.Buttons[e.PackageIndex].Installed = true; if (updateEngine.LastCheckResult.PackagesToUpdate.Count != e.PackageIndex + 1) { packageScroller.ScrollToButton(e.PackageIndex + 1); LoadPackageInfo(packageScroller.Buttons[e.PackageIndex + 1]); } }
void Updater_PackageDownloadStart(object sender, PMDCP.Updater.PackageDownloadStartEventArgs e) { lblUpdateFound.Text = "Package: " + e.Package.FullID; lblStatus.Hide(); pgbDownloadProgress.Show(); //UpdateStatus("Downloading..."); e.Download.DownloadUpdate += new EventHandler<FileDownloadingEventArgs>(Download_DownloadUpdate); e.Download.DownloadComplete += new EventHandler<FileDownloadingEventArgs>(Download_DownloadComplete); }
internal void PrepOutputStream(Stream s, long streamLength, out CountingStream outputCounter, out Stream encryptor, out Stream deflater, out PMDCP.Compression.Zlib.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 DeflateStream around that. // This will happen BEFORE encryption (if any) as we write data out. deflater = MaybeApplyDeflation(encryptor, streamLength); } else { encryptor = deflater = outputCounter; } // Wrap a CrcCalculatorStream around that. // This will happen BEFORE deflation (if any) as we write data out. output = new PMDCP.Compression.Zlib.CrcCalculatorStream(deflater, true); }