mirror of
https://github.com/crskycode/GARbro.git
synced 2026-07-02 03:10:26 +08:00
added callback into archive creation method.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -96,9 +96,17 @@ namespace GameRes
|
||||
|
||||
public class ResourceOptions
|
||||
{
|
||||
public object Widget { get; set; }
|
||||
}
|
||||
|
||||
public enum ArchiveOperation
|
||||
{
|
||||
Abort,
|
||||
Skip,
|
||||
Continue,
|
||||
}
|
||||
|
||||
public delegate ArchiveOperation EntryCallback (int num, Entry entry, string description);
|
||||
|
||||
public abstract class ArchiveFormat : IResource
|
||||
{
|
||||
public override string Type { get { return "archive"; } }
|
||||
@@ -149,12 +157,28 @@ namespace GameRes
|
||||
/// Create resource wihin stream <paramref name="file"/> containing entries from the
|
||||
/// supplied <paramref name="list"/> and applying necessary <paramref name="options"/>.
|
||||
/// </summary>
|
||||
public virtual void Create (Stream file, IEnumerable<Entry> list, ResourceOptions options = null)
|
||||
public virtual void Create (Stream file, IEnumerable<Entry> list, ResourceOptions options = null,
|
||||
EntryCallback callback = null)
|
||||
{
|
||||
throw new NotImplementedException ("ArchiveFormat.Create is not implemented");
|
||||
}
|
||||
|
||||
public virtual ResourceOptions GetOptions ()
|
||||
public virtual ResourceOptions GetDefaultOptions ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual ResourceOptions GetOptions (object widget)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual object GetCreationWidget ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual object GetAccessWidget ()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -178,6 +202,11 @@ namespace GameRes
|
||||
/// Return value from ShowDialog()
|
||||
/// </summary>
|
||||
public bool InputResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Archive-specific options set by InputWidget.
|
||||
/// </summary>
|
||||
public ResourceOptions Options { get; set; }
|
||||
}
|
||||
|
||||
public sealed class FormatCatalog
|
||||
|
||||
Reference in New Issue
Block a user