2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2020-03-24 13:13:46 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.IO.Archives
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2021-11-12 14:09:01 +08:00
|
|
|
|
/// Allows reading a single file from the provided byte array.
|
2020-03-24 13:13:46 +08:00
|
|
|
|
/// </summary>
|
2023-09-14 12:36:07 +08:00
|
|
|
|
public class ByteArrayArchiveReader : ArchiveReader
|
2020-03-24 13:13:46 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly byte[] content;
|
|
|
|
|
|
2023-09-14 12:36:07 +08:00
|
|
|
|
public ByteArrayArchiveReader(byte[] content, string filename)
|
2020-03-24 13:13:46 +08:00
|
|
|
|
: base(filename)
|
|
|
|
|
{
|
|
|
|
|
this.content = content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Stream GetStream(string name) => new MemoryStream(content);
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<string> Filenames => new[] { Name };
|
|
|
|
|
}
|
|
|
|
|
}
|