mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-22 23:15:20 +00:00
add entryExtractionEvent for stream
This commit is contained in:
17
SharpCompress/Common/ReaderExtractionEventArgs.cs
Normal file
17
SharpCompress/Common/ReaderExtractionEventArgs.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace SharpCompress.Common
|
||||
{
|
||||
public class ReaderExtractionEventArgs<T>:EventArgs
|
||||
{
|
||||
internal ReaderExtractionEventArgs(T entry)
|
||||
{
|
||||
Item = entry;
|
||||
}
|
||||
public T Item { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -2,18 +2,20 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using SharpCompress.Archive;
|
||||
using SharpCompress.Archive.Rar;
|
||||
using SharpCompress.Common;
|
||||
|
||||
#if PORTABLE
|
||||
using SharpCompress.Common.Rar.Headers;
|
||||
#endif
|
||||
using SharpCompress.Reader.Rar;
|
||||
|
||||
namespace SharpCompress.Reader
|
||||
{
|
||||
/// <summary>
|
||||
/// A generic push reader that reads unseekable comrpessed streams.
|
||||
/// </summary>
|
||||
public abstract class AbstractReader<TEntry, TVolume> : IReader, IExtractionListener
|
||||
public abstract class AbstractReader<TEntry, TVolume> : IReader, IReaderExtractionListener
|
||||
where TEntry : Entry
|
||||
where TVolume : Volume
|
||||
{
|
||||
@@ -21,9 +23,14 @@ namespace SharpCompress.Reader
|
||||
private IEnumerator<TEntry> entriesForCurrentReadStream;
|
||||
private bool wroteCurrentEntry;
|
||||
|
||||
public event EventHandler<ReaderExtractionEventArgs<IEntry>> EntryExtractionBegin;
|
||||
public event EventHandler<ReaderExtractionEventArgs<IEntry>> EntryExtractionEnd;
|
||||
|
||||
public event EventHandler<CompressedBytesReadEventArgs> CompressedBytesRead;
|
||||
public event EventHandler<FilePartExtractionBeginEventArgs> FilePartExtractionBegin;
|
||||
|
||||
|
||||
|
||||
internal AbstractReader(Options options, ArchiveType archiveType)
|
||||
{
|
||||
ArchiveType = archiveType;
|
||||
@@ -163,7 +170,11 @@ namespace SharpCompress.Reader
|
||||
throw new ArgumentNullException(
|
||||
"A writable Stream was required. Use Cancel if that was intended.");
|
||||
}
|
||||
|
||||
var streamListener = this as IReaderExtractionListener;
|
||||
streamListener.FireEntryExtractionBegin(this.Entry);
|
||||
Write(writableStream);
|
||||
streamListener.FireEntryExtractionEnd(this.Entry);
|
||||
wroteCurrentEntry = true;
|
||||
}
|
||||
|
||||
@@ -222,5 +233,21 @@ namespace SharpCompress.Reader
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void IReaderExtractionListener.FireEntryExtractionBegin(Entry entry)
|
||||
{
|
||||
if (EntryExtractionBegin!=null)
|
||||
{
|
||||
EntryExtractionBegin(this, new ReaderExtractionEventArgs<IEntry>(entry));
|
||||
}
|
||||
}
|
||||
|
||||
void IReaderExtractionListener.FireEntryExtractionEnd(Entry entry)
|
||||
{
|
||||
if (EntryExtractionEnd!=null)
|
||||
{
|
||||
EntryExtractionEnd(this, new ReaderExtractionEventArgs<IEntry>(entry));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,9 @@ namespace SharpCompress.Reader
|
||||
{
|
||||
public interface IReader : IDisposable
|
||||
{
|
||||
event EventHandler<ReaderExtractionEventArgs<IEntry>> EntryExtractionBegin;
|
||||
event EventHandler<ReaderExtractionEventArgs<IEntry>> EntryExtractionEnd;
|
||||
|
||||
event EventHandler<CompressedBytesReadEventArgs> CompressedBytesRead;
|
||||
event EventHandler<FilePartExtractionBeginEventArgs> FilePartExtractionBegin;
|
||||
|
||||
|
||||
16
SharpCompress/Reader/IReaderExtractionListener.cs
Normal file
16
SharpCompress/Reader/IReaderExtractionListener.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using SharpCompress.Archive;
|
||||
using SharpCompress.Common;
|
||||
|
||||
namespace SharpCompress.Reader
|
||||
{
|
||||
internal interface IReaderExtractionListener:IExtractionListener
|
||||
{
|
||||
// void EnsureEntriesLoaded();
|
||||
void FireEntryExtractionBegin(Entry entry);
|
||||
void FireEntryExtractionEnd(Entry entry);
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
<SignAssembly>false</SignAssembly>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyOriginatorKeyFile>SharpCompress.pfx</AssemblyOriginatorKeyFile>
|
||||
@@ -133,6 +133,7 @@
|
||||
<Compile Include="Common\IVolume.cs" />
|
||||
<Compile Include="Common\Rar\RarCryptoWrapper.cs" />
|
||||
<Compile Include="Common\Rar\RarRijndael.cs" />
|
||||
<Compile Include="Common\ReaderExtractionEventArgs.cs" />
|
||||
<Compile Include="Common\SevenZip\CBindPair.cs" />
|
||||
<Compile Include="Common\SevenZip\CCoderInfo.cs" />
|
||||
<Compile Include="Common\SevenZip\CFileItem.cs" />
|
||||
@@ -249,6 +250,7 @@
|
||||
<Compile Include="Common\Rar\RarCryptoBinaryReader.cs" />
|
||||
<Compile Include="IO\RewindableStream.cs" />
|
||||
<Compile Include="Reader\GZip\GZipReader.cs" />
|
||||
<Compile Include="Reader\IReaderExtractionListener.cs" />
|
||||
<Compile Include="Reader\ReaderFactory.cs" />
|
||||
<Compile Include="Reader\AbstractReader.cs" />
|
||||
<Compile Include="Common\Volume.cs" />
|
||||
|
||||
Reference in New Issue
Block a user