Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kekyo committed Jan 3, 2025
1 parent 9c2253a commit 53e17dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 62 deletions.
9 changes: 8 additions & 1 deletion chibiar/chibiar.core.Tests/ArchiverTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down
61 changes: 0 additions & 61 deletions toolchain.common/Archiving/StreamDemuxer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,67 +98,6 @@ public void Skip(Entry entry)

public void Finish(Entry entry) =>
this.ids.Remove(entry.Id);

private readonly Dictionary<int, SubStream> subStreams = new();

public Stream? Next(Func<string, bool> 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
Expand Down
1 change: 1 addition & 0 deletions toolchain.common/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]

0 comments on commit 53e17dc

Please sign in to comment.