public override int Read(byte[] buffer, int offset, int count) { if (position == 0 && zipEntry.IsCrypted && ((ZipInputStream)zipStream).Password == null && PasswordRequired != null) { CompressionPasswordRequiredEventArgs e = new CompressionPasswordRequiredEventArgs(); PasswordRequired(this, e); if (e.ContinueOperation && e.Password.Length > 0) ((ZipInputStream)zipStream).Password = e.Password; } // TODO: always save to a local temp circular buffer for optimization of the backwards seek. int total = zipStream.Read(buffer, offset, count); position += total; if (ExtractionProgress != null) { CompressionExtractionProgressEventArgs e = new CompressionExtractionProgressEventArgs(); e.BytesExtracted = position; e.FileName = zipEntry.Name; e.FileSize = zipEntry.Size; e.PercentComplete = 100.0 * position / zipEntry.Size; ExtractionProgress(this, e); } return total; }
protected virtual int OnDataAvailable(IntPtr p1, int p2) { int result=1; if(this.currentFile!=null) this.currentFile.BytesExtracted+=p2; if(this.DataAvailable!=null) { byte[] data=new byte[p2]; Marshal.Copy(p1, data, 0, p2); DataAvailableEventArgs e=new DataAvailableEventArgs(data); this.DataAvailable(this, e); if(!e.ContinueOperation) result=-1; } if((this.ExtractionProgress!=null) && (this.currentFile!=null)) { CompressionExtractionProgressEventArgs e = new CompressionExtractionProgressEventArgs(); e.FileName=this.currentFile.FileName; e.FileSize=this.currentFile.UnpackedSize; e.BytesExtracted=this.currentFile.BytesExtracted; e.PercentComplete=this.currentFile.PercentComplete; this.ExtractionProgress(this, e); if(!e.ContinueOperation) result=-1; } return result; }
//private void CDReadProgress(object sender, ReadProgressArgs e) //{ // CheckStop(); // if (this.CUEToolsProgress == null) // return; // ICDRipper audioSource = (ICDRipper)sender; // int processed = e.Position - e.PassStart; // TimeSpan elapsed = DateTime.Now - e.PassTime; // double speed = elapsed.TotalSeconds > 0 ? processed / elapsed.TotalSeconds / 75 : 1.0; // _progress.percentDisk = (double)(e.PassStart + (processed + e.Pass * (e.PassEnd - e.PassStart)) / (audioSource.CorrectionQuality + 1)) / audioSource.TOC.AudioLength; // _progress.percentTrck = (double) (e.Position - e.PassStart) / (e.PassEnd - e.PassStart); // _progress.offset = 0; // _progress.status = string.Format("Ripping @{0:00.00}x {1}", speed, e.Pass > 0 ? " (Retry " + e.Pass.ToString() + ")" : ""); // this.CUEToolsProgress(this, _progress); //} private void unzip_ExtractionProgress(object sender, CompressionExtractionProgressEventArgs e) { CheckStop(); if (this.CUEToolsProgress == null) return; _progress.percent = e.PercentComplete / 100; this.CUEToolsProgress(this, _progress); }