2017-02-07 13:59:30 +09:00
|
|
|
|
// 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 18:56:20 +09:00
|
|
|
|
|
|
|
|
|
using System;
|
2016-10-04 16:29:08 -04:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
2016-11-05 20:00:14 +09:00
|
|
|
|
using osu.Framework.IO.Stores;
|
2016-10-04 16:29:08 -04:00
|
|
|
|
|
2017-03-14 11:46:34 +09:00
|
|
|
|
namespace osu.Game.Beatmaps.IO
|
2016-10-13 23:33:58 -04:00
|
|
|
|
{
|
2016-11-05 20:00:14 +09:00
|
|
|
|
public abstract class ArchiveReader : IDisposable, IResourceStore<byte[]>
|
2016-10-13 23:33:58 -04:00
|
|
|
|
{
|
2017-02-09 15:09:48 +01:00
|
|
|
|
/// <summary>
|
2016-10-13 23:33:58 -04:00
|
|
|
|
/// Opens a stream for reading a specific file from this archive.
|
|
|
|
|
/// </summary>
|
2016-11-05 20:00:14 +09:00
|
|
|
|
public abstract Stream GetStream(string name);
|
2016-10-10 09:26:34 -04:00
|
|
|
|
|
2016-10-13 23:33:58 -04:00
|
|
|
|
public abstract void Dispose();
|
2016-11-05 20:00:14 +09:00
|
|
|
|
|
2017-07-26 20:22:02 +09:00
|
|
|
|
public abstract IEnumerable<string> Filenames { get; }
|
|
|
|
|
|
2016-11-05 20:00:14 +09:00
|
|
|
|
public virtual byte[] Get(string name)
|
|
|
|
|
{
|
|
|
|
|
using (Stream input = GetStream(name))
|
|
|
|
|
{
|
|
|
|
|
if (input == null)
|
|
|
|
|
return null;
|
|
|
|
|
|
2017-05-08 19:41:22 +08:00
|
|
|
|
byte[] buffer = new byte[input.Length];
|
|
|
|
|
input.Read(buffer, 0, buffer.Length);
|
|
|
|
|
return buffer;
|
2016-11-05 20:00:14 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-05-23 16:26:51 +09:00
|
|
|
|
|
|
|
|
|
public abstract Stream GetUnderlyingStream();
|
2016-10-13 23:33:58 -04:00
|
|
|
|
}
|
2016-10-04 16:29:08 -04:00
|
|
|
|
}
|