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