private void OnFileExtractionFinished(FileInfoEventArgs e)
 {
     if (FileExtractionFinished != null)
     {
         FileExtractionFinished(this, e);
     }
 }
        /// <summary>
        /// Called when the archive was extracted
        /// </summary>
        /// <param name="operationResult"></param>
        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;
                }
            }
            else
            {
                if (_fileStream != null && !_fileIndex.HasValue)
                {
                    try
                    {
                        _fileStream.BytesWritten -= IntEventArgsHandler;
                        _fileStream.Dispose();
                    }
                    catch (ObjectDisposedException) { }
                    _fileStream = null;
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                }
                var iea = new FileInfoEventArgs(
                    _extractor.ArchiveFileData[_currentIndex], PercentDoneEventArgs.ProducePercentDone(_doneRate));
                OnFileExtractionFinished(iea);
                if (iea.Cancel)
                {
                    Canceled = true;
                }
            }
        }
Пример #3
0
 void extr_FileExtractionStarted(object sender, FileInfoEventArgs e)
 {
     StatusRichTextBox.Text += String.Format("[{0}] Extracting \"{1}\"" + Environment.NewLine, DateTime.Now.ToString("dd.MM.yyyy - HH.mm.ss"), e.FileInfo.FileName);
 }
        private void FileExtractionFinished(object sender, FileInfoEventArgs e)
        {
            //pb_totaalfiles.Invoke(new FileInfoEvent((object o, FileInfoEventArgs l) =>
            //{
            //    pb_totaalfiles.Value += (int)(100 / _sevenZipExtractor.FilesCount);
            //}),sender,e);

            pb_compression.Invoke(new InvokeEvent((object o, EventArgs l) =>
            {
                pb_compression.Value = 100;
            }), sender, e);
        }
Пример #5
0
		/// <summary>
		/// Called when a file has been extracted from a source archive.
		/// </summary>
		/// <remarks>
		/// This notifies listeners that a read-only initialization step has finished.
		/// </remarks>
		/// <param name="sender">The object that raised the event.</param>
		/// <param name="e">An <see cref="EventArgs"/> describing the event arguments.</param>
		private void FileExtractionFinished(object sender, FileInfoEventArgs e)
		{
			CancelProgressEventArgs ceaArgs = new CancelProgressEventArgs((float)e.PercentDone / 100f);
			ReadOnlyInitProgressUpdated(this, ceaArgs);
			e.Cancel = ceaArgs.Cancel;
		}
Пример #6
0
        private void FileExtractionFinishedHandler(object sender, FileInfoEventArgs args)
        {
            if (!PassThru) return;

            string relArchivePathName = args.FileInfo.FileName;
            if (this.FlattenPaths)
            {
                string leafName = System.IO.Path.GetFileName(relArchivePathName);
                string destPath = System.IO.Path.Combine(OutputPath.ProviderPath, leafName);
                if (args.FileInfo.IsDirectory)
                {
                    WriteObject(new DirectoryInfo(destPath));
                }
                else
                {
                    WriteObject(new FileInfo(destPath));
                }
            }
            else
            {
                string destPath = System.IO.Path.Combine(OutputPath.ProviderPath, relArchivePathName);
                if (args.FileInfo.IsDirectory)
                {
                    WriteObject(new DirectoryInfo(destPath));
                }
                else
                {
                    WriteObject(new FileInfo(destPath));
                }
            }
        }
Пример #7
0
 /// <summary>
 /// Called when a file is about to be extracted from a fomod.
 /// </summary>
 /// <remarks>
 /// This cancels the compression if the user has clicked the cancel button of the progress dialog.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">A <see cref="FileNameEventArgs"/> describing the event arguments.</param>
 void UnpackFomod_FileExtractionStarted(object sender, FileInfoEventArgs e)
 {
     e.Cancel = m_bwdProgress.Cancelled();
 }
Пример #8
0
 /// <summary>
 ///   Called when a file is about to be extracted from a source archive.
 /// </summary>
 /// <remarks>
 ///   This cancels the compression if the user has clicked the cancel button of the progress dialog.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">A <see cref="FileNameEventArgs" /> describing the event arguments.</param>
 private void FileExtractionStarted(object sender, FileInfoEventArgs e)
 {
   e.Cancel = ProgressDialog.Cancelled();
 }
        /// <summary>
        /// Sets output stream for writing unpacked data
        /// </summary>
        /// <param name="index">Current file index</param>
        /// <param name="outStream">Output stream pointer</param>
        /// <param name="askExtractMode">Extraction mode</param>
        /// <returns>0 if OK</returns>
        public int GetStream(uint index, out ISequentialOutStream outStream, AskMode askExtractMode)
        {
            outStream = null;

            if (Canceled)
            {
                return(-1);
            }
            _currentIndex = (int)index;
            if (askExtractMode == AskMode.Extract)
            {
                var fileName = _directory;
                if (!_fileIndex.HasValue)
                {
                    #region Extraction to a file

                    if (_actualIndexes == null || _actualIndexes.Contains(index))
                    {
                        var data = new PropVariant();
                        _archive.GetProperty(index, ItemPropId.Path, ref data);
                        string entryName = NativeMethods.SafeCast(data, "");

                        #region Get entryName

                        if (String.IsNullOrEmpty(entryName))
                        {
                            if (_filesCount == 1)
                            {
                                var archName = Path.GetFileName(_extractor.FileName);
                                archName = archName.Substring(0, archName.LastIndexOf('.'));
                                if (!archName.EndsWith(".tar", StringComparison.OrdinalIgnoreCase))
                                {
                                    archName += ".tar";
                                }
                                entryName = archName;
                            }
                            else
                            {
                                entryName = "[no name] " + index.ToString(CultureInfo.InvariantCulture);
                            }
                        }

                        #endregion

                        try
                        {
                            fileName = Path.Combine(RemoveIllegalCharacters(_directory, true), RemoveIllegalCharacters(_directoryStructure ? entryName : Path.GetFileName(entryName)));
                            ValidateFileNameAndCreateDirectory(fileName);
                        }
                        catch (Exception e)
                        {
                            AddException(e);
                            goto FileExtractionStartedLabel;
                        }

                        _archive.GetProperty(index, ItemPropId.IsDirectory, ref data);
                        if (!NativeMethods.SafeCast(data, false))
                        {
                            #region Branch

                            _archive.GetProperty(index, ItemPropId.LastWriteTime, ref data);
                            var time = NativeMethods.SafeCast(data, DateTime.MinValue);
                            if (File.Exists(fileName))
                            {
                                var fnea = new FileOverwriteEventArgs(fileName);
                                OnFileExists(fnea);
                                if (fnea.Cancel)
                                {
                                    Canceled = true;
                                    return(-1);
                                }
                                if (String.IsNullOrEmpty(fnea.FileName))
                                {
                                    outStream = _fakeStream;

                                    goto FileExtractionStartedLabel;
                                }
                                fileName = fnea.FileName;
                            }
                            try
                            {
                                _fileStream = new OutStreamWrapper(File.Create(fileName), fileName, time, true);
                            }
                            catch (Exception e)
                            {
                                if (e is FileNotFoundException)
                                {
                                    AddException(
                                        new IOException("The file \"" + fileName +
                                                        "\" was not extracted due to the File.Create fail."));
                                }
                                else
                                {
                                    AddException(e);
                                }
                                outStream = _fakeStream;
                                goto FileExtractionStartedLabel;
                            }
                            _fileStream.BytesWritten += IntEventArgsHandler;
                            outStream = _fileStream;

                            #endregion
                        }
                        else
                        {
                            #region Branch

                            if (!Directory.Exists(fileName))
                            {
                                try
                                {
                                    Directory.CreateDirectory(fileName);
                                }
                                catch (Exception e)
                                {
                                    AddException(e);
                                }
                                outStream = _fakeStream;
                            }

                            #endregion
                        }
                    }
                    else
                    {
                        outStream = _fakeStream;
                    }

                    #endregion
                }
                else
                {
                    #region Extraction to a stream

                    if (index == _fileIndex)
                    {
                        outStream  = _fileStream;
                        _fileIndex = null;
                    }
                    else
                    {
                        outStream = _fakeStream;
                    }

                    #endregion
                }

FileExtractionStartedLabel:
                _doneRate += 1.0f / _filesCount;
                var iea = new FileInfoEventArgs(
                    _extractor.ArchiveFileData[(int)index], PercentDoneEventArgs.ProducePercentDone(_doneRate));
                OnFileExtractionStarted(iea);
                if (iea.Cancel)
                {
                    if (!String.IsNullOrEmpty(fileName))
                    {
                        _fileStream.Dispose();
                        if (File.Exists(fileName))
                        {
                            try
                            {
                                File.Delete(fileName);
                            }
                            catch (Exception e)
                            {
                                AddException(e);
                            }
                        }
                    }
                    Canceled = true;
                    return(-1);
                }
            }
            return(0);
        }
 /// <summary>
 /// Event proxy for FileExtractionFinished.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">The event arguments.</param>
 private void FileExtractionFinishedEventProxy(object sender, FileInfoEventArgs e)
 {
     OnEvent(FileExtractionFinished, e, true);
 }
Пример #11
0
 static void extr_FileExtractionStarted(object sender, FileInfoEventArgs e) {
 }
        private void FileExtractionStarted(object sender, FileInfoEventArgs e)
        {
            //when the next file is being compressed.
            lbl_commpressing_file.Invoke(new FileInfoEvent((object o, FileInfoEventArgs l) =>
            {
                lbl_commpressing_file.Text = String.Format(_commpressingFileName, l.FileInfo.FileName);
            }), sender, e);

            pb_totaalfiles.Invoke(new FileInfoEvent((object o, FileInfoEventArgs l) =>
            {
                pb_totaalfiles.Value = l.PercentDone;
            }), sender, e);

            pb_compression.Invoke(new InvokeEvent((object o, EventArgs l) =>
            {
                pb_compression.Value = 0;
            }), sender, e);
        }
Пример #13
0
 void extr_FileExtractionStarted(object sender, FileInfoEventArgs e)
 {
     l_ExtractProgress.Text = String.Format("Extracting \"{0}\"", e.FileInfo.FileName);
     l_ExtractProgress.Refresh();
     pb_ExtractWork.Increment(1);
     pb_ExtractWork.Refresh();
 }
Пример #14
0
 void extr_FileExtractionStarted(object sender, FileInfoEventArgs e)
 {
     tb_Messages.Text += String.Format("Extracting \"{0}\"" + Environment.NewLine, e.FileInfo.FileName);
     tb_Messages.ScrollToEnd();
     pb_Extract2.Value += 1;
 }
 /// <summary>
 /// Event proxy for FileExtractionFinished.
 /// </summary>
 /// <param name="sender">The sender of the event.</param>
 /// <param name="e">The event arguments.</param>
 private void FileExtractionFinishedEventProxy(object sender, FileInfoEventArgs e)
 {
     OnEvent(FileExtractionFinished, e, true);
 }
Пример #16
0
		/// <summary>
		/// Handles the <see cref="SevenZipExtractor.FileExtractionStarted"/> event of
		/// the archive extractors.
		/// </summary>
		/// <remarks>
		/// This cancels the extraction if the user has cancelled the task.
		/// </remarks>
		/// <param name="sender">The object that raised the event.</param>
		/// <param name="e">A <see cref="FileInfoEventArgs"/> describing the event arguments.</param>
		private void Extractor_FileExtractionStarted(object sender, FileInfoEventArgs e)
		{
			e.Cancel = Status == TaskStatus.Cancelling;
		}
Пример #17
0
		/// <summary>
		/// Handles the <see cref="SevenZipExtractor.FileExtractionFinished"/> event of
		/// the archive extractors.
		/// </summary>
		/// <remarks>
		/// This cancels the extraction if the user has cancelled the task. This also updates
		/// the item progress.
		/// </remarks>
		/// <param name="sender">The object that raised the event.</param>
		/// <param name="e">A <see cref="FileInfoEventArgs"/> describing the event arguments.</param>
		private void Extractor_FileExtractionFinished(object sender, FileInfoEventArgs e)
		{
			e.Cancel = Status == TaskStatus.Cancelling;
			StepItemProgress();
		}
Пример #18
0
		/// <summary>
		/// Called when a file is about to be extracted from a source archive.
		/// </summary>
		/// <remarks>
		/// This notifies listeners that a read-only initialization step has started.
		/// </remarks>
		/// <param name="sender">The object that raised the event.</param>
		/// <param name="e">A <see cref="FileNameEventArgs"/> describing the event arguments.</param>
		private void FileExtractionStarted(object sender, FileInfoEventArgs e)
		{
			CancelEventArgs ceaArgs = new CancelEventArgs(false);
			ReadOnlyInitStepStarted(this, ceaArgs);
			e.Cancel = ceaArgs.Cancel;
		}
Пример #19
0
 private void OnFileExtractionFinished(FileInfoEventArgs e)
 {
     if (FileExtractionFinished != null)
     {
         FileExtractionFinished(this, e);
     }
 }
        /// <summary>
        /// Called when the archive was extracted
        /// </summary>
        /// <param name="operationResult"></param>
        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;
                }
            }
            else
            {
                if (_fileStream != null && !_fileIndex.HasValue)
                {
                    try
                    {
                        _fileStream.BytesWritten -= IntEventArgsHandler;
                        _fileStream.Dispose();
                    }
                    catch (ObjectDisposedException) { }
                    _fileStream = null;
                }
                var iea = new FileInfoEventArgs(
                    _extractor.ArchiveFileData[_currentIndex], PercentDoneEventArgs.ProducePercentDone(_doneRate));
                OnFileExtractionFinished(iea);
                if (iea.Cancel)
                {
                    Canceled = true;
                }
            }
        }
Пример #21
0
 /// <summary>
 ///   Called when a file has been extracted from a source archive.
 /// </summary>
 /// <remarks>
 ///   This steps the progress of the create fomod from archive progress dialog.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">An <see cref="EventArgs" /> describing the event arguments.</param>
 private void FileExtractionFinished(object sender, FileInfoEventArgs e)
 {
   ProgressDialog.StepItemProgress();
 }
Пример #22
0
 void extractor_FileExtractionStarted(object sender, FileInfoEventArgs e)
 {
     //throw new NotImplementedException();
 }
Пример #23
0
 /// <summary>
 /// Called when a file has been extracted from a fomod.
 /// </summary>
 /// <remarks>
 /// This steps the progress of the create fomod from archive progress dialog.
 /// </remarks>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="e">An <see cref="EventArgs"/> describing the event arguments.</param>
 void UnpackFomod_FileExtractionFinished(object sender, FileInfoEventArgs e)
 {
     m_bwdProgress.StepItemProgress();
 }