diff --git a/chibiar/chibiar.core.Tests/ArchiverTests.cs b/chibiar/chibiar.core.Tests/ArchiverTests.cs index 7f1b7ab..f23f8e5 100644 --- a/chibiar/chibiar.core.Tests/ArchiverTests.cs +++ b/chibiar/chibiar.core.Tests/ArchiverTests.cs @@ -16,7 +16,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; - +using chibicc.toolchain.IO; using static VerifyNUnit.Verifier; using static chibiar.ArchiverTestRunner; @@ -58,6 +58,13 @@ public Task ArchiveOne() Assert.That(actual, Is.True); + using var archiveStream = StreamUtilities.OpenStream(archivePath, false); + var demuxer = new StreamDemuxer(archiveStream); + + + demuxer.Run( + (id, name) => ); + using var zip = ZipFile.OpenRead(archivePath); Assert.That( diff --git a/toolchain.common/Archiving/StreamDemuxer.cs b/toolchain.common/Archiving/StreamDemuxer.cs index 786469d..8677203 100644 --- a/toolchain.common/Archiving/StreamDemuxer.cs +++ b/toolchain.common/Archiving/StreamDemuxer.cs @@ -98,67 +98,6 @@ public void Skip(Entry entry) public void Finish(Entry entry) => this.ids.Remove(entry.Id); - - private readonly Dictionary subStreams = new(); - - public Stream? Next(Func predicate) - { - if (this.Prepare() is not { } entry) - { - return null; - } - bool fetch; - if (entry.Name is { } name) - { - fetch = predicate(name); - ids.Add(entry.Id, fetch); - } - else - { - if (!ids.TryGetValue(entry.Id, out fetch)) - { - throw new FormatException("Invalid archive format."); - } - } - } - - private sealed class SubStream : Stream - { - private readonly StreamDemuxer parent; - - public SubStream(StreamDemuxer parent) => - this.parent = parent; - - public override bool CanRead => - true; - public override bool CanSeek => - false; - public override bool CanWrite => - false; - public override long Length => - throw new InvalidOperationException(); - - public override long Position - { - get => throw new InvalidOperationException(); - set => throw new InvalidOperationException(); - } - - public override int Read(byte[] buffer, int offset, int count) - { - } - - public override void Flush() - { - } - - public override long Seek(long offset, SeekOrigin origin) => - throw new InvalidOperationException(); - public override void SetLength(long value) => - throw new InvalidOperationException(); - public override void Write(byte[] buffer, int offset, int count) => - throw new InvalidOperationException(); - } } internal static class StreamDemuxerExtension diff --git a/toolchain.common/Properties/AssemblyInfo.cs b/toolchain.common/Properties/AssemblyInfo.cs index 1d44976..7eabf72 100644 --- a/toolchain.common/Properties/AssemblyInfo.cs +++ b/toolchain.common/Properties/AssemblyInfo.cs @@ -12,4 +12,5 @@ [assembly: InternalsVisibleTo("chibiar.core")] [assembly: InternalsVisibleTo("chibias.core")] [assembly: InternalsVisibleTo("chibild.core")] +[assembly: InternalsVisibleTo("chibiar.core.Tests")] [assembly: InternalsVisibleTo("chibild.core.Tests")]