1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 14:07:27 +08:00
osu-lazer/osu.Game/Beatmaps/IO/ArchiveReader.cs

37 lines
1.1 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2016-12-06 17:56:20 +08:00
using System;
using System.Collections.Generic;
using System.IO;
2016-11-05 19:00:14 +08:00
using osu.Framework.IO.Stores;
namespace osu.Game.Beatmaps.IO
{
2016-11-05 19:00:14 +08:00
public abstract class ArchiveReader : IDisposable, IResourceStore<byte[]>
{
/// <summary>
/// Opens a stream for reading a specific file from this archive.
/// </summary>
2016-11-05 19:00:14 +08:00
public abstract Stream GetStream(string name);
public abstract void Dispose();
2016-11-05 19:00:14 +08:00
public abstract IEnumerable<string> Filenames { get; }
2016-11-05 19:00:14 +08:00
public virtual byte[] Get(string name)
{
using (Stream input = GetStream(name))
{
if (input == null)
return null;
byte[] buffer = new byte[input.Length];
input.Read(buffer, 0, buffer.Length);
return buffer;
2016-11-05 19:00:14 +08:00
}
}
2017-05-23 15:26:51 +08:00
public abstract Stream GetUnderlyingStream();
}
}