added callback into archive creation method.

This commit is contained in:
morkt
2014-07-27 03:37:51 +04:00
parent c13b9bb12e
commit 08b8e8a46b
9 changed files with 211 additions and 81 deletions

View File

@@ -11,13 +11,6 @@ using System.Diagnostics;
namespace GameRes
{
public enum ExtractAction
{
Abort,
Skip,
Continue,
}
public class ArcFile : IDisposable
{
private ArcView m_arc;
@@ -36,8 +29,6 @@ namespace GameRes
/// <summary>Archive contents.</summary>
public ICollection<Entry> Dir { get { return m_dir; } }
public delegate ExtractAction ExtractCallback (int num, Entry entry);
public ArcFile (ArcView arc, ArchiveFormat impl, ICollection<Entry> dir)
{
m_arc = arc;
@@ -93,15 +84,15 @@ namespace GameRes
/// Extract all entries from the archive into current directory.
/// <paramref name="callback"/> could be used to observe/control extraction process.
/// </summary>
public void ExtractFiles (ExtractCallback callback)
public void ExtractFiles (EntryCallback callback)
{
int i = 0;
foreach (var entry in Dir.OrderBy (e => e.Offset))
{
var action = callback (i, entry);
if (ExtractAction.Abort == action)
var action = callback (i, entry, null);
if (ArchiveOperation.Abort == action)
break;
if (ExtractAction.Skip != action)
if (ArchiveOperation.Skip != action)
Extract (entry);
++i;
}