示例#1
0
        public void SetOperationResult(OperationResult operationResult)
        {
            if (operationResult != OperationResult.Ok && ReportErrors)
            {
                if (_fileStream != null)
                {
                    try
                    {
                        _fileStream.Dispose();
                    }
                    catch (ObjectDisposedException) { }
                    _fileStream = null;
                }

                switch (operationResult)
                {
                case OperationResult.CrcError:
                    AddException(new ExtractionFailedException("File is corrupted. Crc check has failed."));
                    break;

                case OperationResult.DataError:
                    AddException(new ExtractionFailedException("File is corrupted. Data error has occured."));
                    break;

                case OperationResult.UnsupportedMethod:
                    AddException(new ExtractionFailedException("Unsupported method error has occured."));
                    break;
                }
            }
            if (_fileStream != null)
            {
                _fileStream.BytesRead -= IntEventArgsHandler;
                //Specific Zip implementation - can not Dispose files for Zip.
                if (_compressor.ArchiveFormat != OutArchiveFormat.Zip)
                {
                    try
                    {
                        _fileStream.Dispose();
                    }
                    catch (ObjectDisposedException) {}
                }
                else
                {
                    _wrappersToDispose.Add(_fileStream);
                }
                _fileStream = null;
                //remove useless GC.collect
//                GC.Collect();
                // Issue #6987
                //GC.WaitForPendingFinalizers();
            }
            OnFileCompressionFinished(EventArgs.Empty);
        }
示例#2
0
        public void SetOperationResult(OperationResult operationResult)
        {
            if (operationResult != OperationResult.Ok && ReportErrors)
            {
                switch (operationResult)
                {
                case OperationResult.CrcError:
                    AddException(new ExtractionFailedException("File is corrupted. Crc check has failed."));
                    break;

                case OperationResult.DataError:
                    AddException(new ExtractionFailedException("File is corrupted. Data error has occured."));
                    break;

                case OperationResult.UnsupportedMethod:
                    AddException(new ExtractionFailedException("Unsupported method error has occured."));
                    break;

                case OperationResult.Unavailable:
                    AddException(new ExtractionFailedException("File is unavailable."));
                    break;

                case OperationResult.UnexpectedEnd:
                    AddException(new ExtractionFailedException("Unexpected end of file."));
                    break;

                case OperationResult.DataAfterEnd:
                    AddException(new ExtractionFailedException("Data after end of archive."));
                    break;

                case OperationResult.IsNotArc:
                    AddException(new ExtractionFailedException("File is not archive."));
                    break;

                case OperationResult.HeadersError:
                    AddException(new ExtractionFailedException("Archive headers error."));
                    break;

                case OperationResult.WrongPassword:
                    AddException(new ExtractionFailedException("Wrong password."));
                    break;

                default:
                    AddException(new ExtractionFailedException($"Unexpected operation result: {operationResult}"));
                    break;
                }
            }
            if (_fileStream != null)
            {
                _fileStream.BytesRead -= IntEventArgsHandler;
                //Specific Zip implementation - can not Dispose files for Zip.
                if (_compressor.ArchiveFormat != OutArchiveFormat.Zip)
                {
                    try
                    {
                        _fileStream.Dispose();
                    }
                    catch (ObjectDisposedException) { }
                }
                else
                {
                    _wrappersToDispose.Add(_fileStream);
                }
                _fileStream = null;
            }
            OnFileCompressionFinished(EventArgs.Empty);
        }