mirror of
https://github.com/adamhathcock/sharpcompress.git
synced 2026-09-24 16:05:27 +00:00
non-async ace works
This commit is contained in:
@@ -66,7 +66,7 @@ namespace SharpCompress.Common.Ace.Headers
|
||||
{
|
||||
// Read header CRC (2 bytes) and header size (2 bytes)
|
||||
var headerBytes = new byte[4];
|
||||
if (stream.Read(headerBytes, 0, 4) != 4)
|
||||
if (!stream.ReadFully(headerBytes))
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
}
|
||||
@@ -80,7 +80,7 @@ namespace SharpCompress.Common.Ace.Headers
|
||||
|
||||
// Read the header data
|
||||
var body = new byte[HeaderSize];
|
||||
if (stream.Read(body, 0, HeaderSize) != HeaderSize)
|
||||
if (!stream.ReadFully(body))
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
}
|
||||
|
||||
@@ -28,9 +28,6 @@ public abstract partial class AceReader : AbstractReader<AceEntry, AceVolume>
|
||||
_archiveEncoding = Options.ArchiveEncoding;
|
||||
}
|
||||
|
||||
private AceReader(Stream stream, ReaderOptions options)
|
||||
: this(options) { }
|
||||
|
||||
/// <summary>
|
||||
/// Derived class must create or manage the Volume itself.
|
||||
/// AbstractReader.Volume is get-only, so it cannot be set here.
|
||||
@@ -43,6 +40,12 @@ public abstract partial class AceReader : AbstractReader<AceEntry, AceVolume>
|
||||
|
||||
protected override IEnumerable<AceEntry> GetEntries(Stream stream)
|
||||
{
|
||||
if (_volume == null)
|
||||
{
|
||||
_volume = new AceVolume(stream, Options, 0);
|
||||
ValidateArchive(_volume);
|
||||
}
|
||||
|
||||
var mainHeaderReader = new AceMainHeader(_archiveEncoding);
|
||||
var mainHeader = mainHeaderReader.Read(stream);
|
||||
if (mainHeader == null)
|
||||
@@ -50,17 +53,11 @@ public abstract partial class AceReader : AbstractReader<AceEntry, AceVolume>
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (mainHeader?.IsMultiVolume == true)
|
||||
if (mainHeader.IsMultiVolume)
|
||||
{
|
||||
throw new MultiVolumeExtractionException("Multi volumes are currently not supported");
|
||||
}
|
||||
|
||||
if (_volume == null)
|
||||
{
|
||||
_volume = new AceVolume(stream, Options, 0);
|
||||
ValidateArchive(_volume);
|
||||
}
|
||||
|
||||
var localHeaderReader = new AceFileHeader(_archiveEncoding);
|
||||
while (true)
|
||||
{
|
||||
|
||||
@@ -191,7 +191,7 @@ public class TestBase : IAsyncDisposable
|
||||
.EnumerateFiles(ORIGINAL_FILES_PATH, "*.*", SearchOption.AllDirectories)
|
||||
.ToLookup(path => Path.GetExtension(path));
|
||||
|
||||
Assert.Equal(extracted.Count, original.Count);
|
||||
Assert.Equal( original.Count, extracted.Count);
|
||||
|
||||
foreach (var orig in original)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user